{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/50158","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/50158/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/50158/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/50158/events","html_url":"https://github.com/rust-lang/rust/issues/50158","id":316591444,"number":50158,"title":"std::sync::Weak::strong_count","user":{"login":"SoniEx2","id":1779619,"avatar_url":"https://avatars2.githubusercontent.com/u/1779619?v=4","gravatar_id":"","url":"https://api.github.com/users/SoniEx2","html_url":"https://github.com/SoniEx2","followers_url":"https://api.github.com/users/SoniEx2/followers","following_url":"https://api.github.com/users/SoniEx2/following{/other_user}","gists_url":"https://api.github.com/users/SoniEx2/gists{/gist_id}","starred_url":"https://api.github.com/users/SoniEx2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SoniEx2/subscriptions","organizations_url":"https://api.github.com/users/SoniEx2/orgs","repos_url":"https://api.github.com/users/SoniEx2/repos","events_url":"https://api.github.com/users/SoniEx2/events{/privacy}","received_events_url":"https://api.github.com/users/SoniEx2/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-04-22T16:09:15Z","updated_at":"2018-04-25T06:26:01Z","closed_at":null,"author_association":"NONE","body":"I'd like to test if a `Weak` is done for without potentially incrementing an atomic refcount, because doing so is slow.\r\n\r\nI want a faster alternative to `Weak.upgrade().is_some()`.\r\n\r\nalso currently have this in my code: https://play.rust-lang.org/?gist=339c2c518a2d42aee7e5a585133427eb&version=stable\r\n\r\n```rust\r\n// since Weaks are completely useless...\r\n// this checks if the arc and weak point to the same value without attempting to upgrade the weak.\r\n// this is \"safer\" than trying to get the strong count\r\nfn compare_arc_weak<T>(arc: &Arc<T>, weak: &Weak<T>) -> bool {\r\n    unsafe {\r\n        // we assume arc and weak have same size and alignment as usize\r\n        let arcusize: usize = mem::transmute_copy(arc);\r\n        let weakusize: usize = mem::transmute_copy(weak);\r\n        arcusize == weakusize\r\n    }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/384174087","html_url":"https://github.com/rust-lang/rust/issues/50158#issuecomment-384174087","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/50158","id":384174087,"user":{"login":"Lymia","id":483849,"avatar_url":"https://avatars2.githubusercontent.com/u/483849?v=4","gravatar_id":"","url":"https://api.github.com/users/Lymia","html_url":"https://github.com/Lymia","followers_url":"https://api.github.com/users/Lymia/followers","following_url":"https://api.github.com/users/Lymia/following{/other_user}","gists_url":"https://api.github.com/users/Lymia/gists{/gist_id}","starred_url":"https://api.github.com/users/Lymia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Lymia/subscriptions","organizations_url":"https://api.github.com/users/Lymia/orgs","repos_url":"https://api.github.com/users/Lymia/repos","events_url":"https://api.github.com/users/Lymia/events{/privacy}","received_events_url":"https://api.github.com/users/Lymia/received_events","type":"User","site_admin":false},"created_at":"2018-04-25T06:26:01Z","updated_at":"2018-04-25T06:26:01Z","author_association":"CONTRIBUTOR","body":"https://github.com/rust-lang/rust/blob/e02868793bdb0e83d2ecee295bdc16f6b2e5a142/src/liballoc/rc.rs#L1228-L1237\r\n\r\nThis function is factually unnecessary for this use case."}}
{"actor":{"display_login":"Lymia"}}