rust/library
Matthias Krüger 4198902e9a
Rollup merge of #138161 - HeroicKatora:heap-peek-mut-refresh, r=dtolnay
Add PeekMut::refresh

I'm not sure if this should go through ACP or not. BinaryHeap is not the most critical data structure in the standard library and it would be understandable if maintainer throughput is thus too limited to accept this PR without a proper design phase that ensures the required understanding of consequence over a longer time period.

This aims to improve the useability of heaps for priority-based work queues. In certain scenarios, modifications on the most relevant or critical items are performed until a condition that determines the work items have been sufficiently addressed. For instance the criticality could be a deadline that is relaxed whenever some part of a work item is completed. Such a loop will repeatedly access the most critical item and put it back in a sorted position when it is complete. Crucially, due to the ordering invariant we know that all necessary work was performed when the completed item remains the most critical. Getting this information from the heap position avoids a (potentially more costly) check on the item state itself.

A customized `drop` with boolean result would avoid up to two more comparisons performed in both the last no-op refresh and Drop code but this occurs once in each execution of the above scenario whereas refresh occurs any number of times. Also note that the comparison overhead of Drop is only taken if the element is mutably inspected to determine the end condition, i.e. not when refresh itself is the break condition.
2025-03-12 08:06:46 +01:00
..
alloc Rollup merge of #138161 - HeroicKatora:heap-peek-mut-refresh, r=dtolnay 2025-03-12 08:06:46 +01:00
alloctests Add comments 2025-03-07 19:11:13 +00:00
backtrace@9d2c34e7e6 Update backtrace 2025-02-13 14:32:50 -08:00
core Auto merge of #128440 - oli-obk:defines, r=lcnr 2025-03-11 18:13:31 +00:00
coretests Update tests. 2025-03-10 12:20:05 +01:00
panic_abort panic_abort: Apply unsafe_op_in_unsafe_fn 2025-02-14 07:36:17 -08:00
panic_unwind library: Use size_of from the prelude instead of imported 2025-03-06 20:20:38 -08:00
portable-simd Remove ignored #[must_use] attributes from portable-simd 2025-02-12 13:59:22 +01:00
proc_macro library: Use size_of from the prelude instead of imported 2025-03-06 20:20:38 -08:00
profiler_builtins compiler & tools dependencies: 2024-12-17 17:41:00 +00:00
rtstartup Mark extern blocks as unsafe 2025-02-09 17:11:13 +00:00
rustc-std-workspace-alloc
rustc-std-workspace-core update rustc-std-workspace crates 2024-11-04 07:45:15 +01:00
rustc-std-workspace-std
std Auto merge of #138366 - matthiaskrgr:rollup-cn16m7q, r=matthiaskrgr 2025-03-11 21:17:18 +00:00
stdarch@9426bb5658 Update stdarch 2025-03-06 11:11:55 -08:00
sysroot Rollup merge of #135501 - tgross35:stdlib-dependencies-private, r=bjorn3 2025-02-23 00:16:18 +01:00
test Use correct error message casing for io::const_errors 2025-02-28 17:50:38 +01:00
unwind Target definition for wasm32-wali-linux-musl to support the Wasm Linux 2025-03-10 21:26:45 -04:00
windows_targets Don't link against advapi32, except on win7. 2025-03-08 10:55:47 -05:00
Cargo.lock Update hermit-abi to 0.5.0 2025-03-09 15:38:29 -07:00
Cargo.toml Move all alloc integration tests to a new alloctests crate 2025-03-07 19:11:11 +00:00