diff options
| author | Josh Stone <jistone@redhat.com> | 2019-02-13 14:07:08 -0800 | 
|---|---|---|
| committer | Josh Stone <jistone@redhat.com> | 2019-02-13 14:07:08 -0800 | 
| commit | 33d80bfaa0f2a4ca996a942e6d65a932e72fec1b (patch) | |
| tree | bdbd444d45849d80840347a43d226d95c081e296 /src/libstd/sys/unix | |
| parent | 70c5af85e09be583128df5eda6b4de25a23387c1 (diff) | |
| download | rust-33d80bfaa0f2a4ca996a942e6d65a932e72fec1b.tar.gz rust-33d80bfaa0f2a4ca996a942e6d65a932e72fec1b.zip | |
Return without a reference in unix Weak::get()
Diffstat (limited to 'src/libstd/sys/unix')
| -rw-r--r-- | src/libstd/sys/unix/weak.rs | 9 | 
1 files changed, 4 insertions, 5 deletions
| diff --git a/src/libstd/sys/unix/weak.rs b/src/libstd/sys/unix/weak.rs index 9b80ad8d9b2..b60e241f10c 100644 --- a/src/libstd/sys/unix/weak.rs +++ b/src/libstd/sys/unix/weak.rs @@ -45,16 +45,15 @@ impl<F> Weak<F> { } } - pub fn get(&self) -> Option<&F> { + pub fn get(&self) -> Option<F> { assert_eq!(mem::size_of::<F>(), mem::size_of::<usize>()); unsafe { if self.addr.load(Ordering::SeqCst) == 1 { self.addr.store(fetch(self.name), Ordering::SeqCst); } - if self.addr.load(Ordering::SeqCst) == 0 { - None - } else { - mem::transmute::<&AtomicUsize, Option<&F>>(&self.addr) + match self.addr.load(Ordering::SeqCst) { + 0 => None, + addr => Some(mem::transmute_copy::<usize, F>(&addr)), } } } | 
