]> git.lizzy.rs Git - rust.git/commit - src/tools/clippy
Rollup merge of #65778 - bdonlan:stable_weak_count, r=dtolnay
authorMazdak Farrokhzad <twingoow@gmail.com>
Mon, 16 Dec 2019 04:23:26 +0000 (05:23 +0100)
committerGitHub <noreply@github.com>
Mon, 16 Dec 2019 04:23:26 +0000 (05:23 +0100)
commitc34ea91a9dbea9b23653dc39cb09e5d412353359
tree9c0a6a2c865a4204d1dde9d4d6885903f33fda55
parenta605441e049f0b6d5f7715b94b8ac4662fd7fcf6
parent9778e03665edbed80eb684ba893abd4e18a0a583
Rollup merge of #65778 - bdonlan:stable_weak_count, r=dtolnay

Stabilize `std::{rc,sync}::Weak::{weak_count, strong_count}`

* Original PR: #56696
* Tracking issue: #57977

Closes: #57977
Supporting comments:

> Although these were added for testing, it is occasionally useful to have a way to probe optimistically for whether a weak pointer has become dangling, without actually taking the overhead of manipulating atomics. Are there any plans to stabilize this?

_Originally posted by @bdonlan in https://github.com/rust-lang/rust/issues/57977#issuecomment-516970921_

> Having this stabilized would help. Currently, the only way to check if a weak pointer has become dangling is to call `upgrade`, which is by far expensive.

_Originally posted by @glebpom in https://github.com/rust-lang/rust/issues/57977#issuecomment-526934709_

Not sure if stabilizing these warrants a full RFC, so throwing this out here as a start for now.

Note: per CONTRIBUTING.md, I ran the tidy checks, but they seem to be failing on unchanged files (primarily in `src/stdsimd`).
src/liballoc/rc.rs
src/liballoc/sync.rs
src/liballoc/sync/tests.rs