Skip to content

Commit

Permalink
Merge #247
Browse files Browse the repository at this point in the history
247: Remove Clone for Guard r=jeehoonkang a=stjepang

While `Guard::clone()` is a nice convenience, it's not really a method we *need*.

By removing the clone impl, we enable some kinds of API. For example, a data structure might want to return a `Guard` to the user and then retrieve it back knowing it has never been cloned.

@Amanieu needs to forbid `Guard::clone()` in a certain use case. I don't remember the exact details, so perhaps he could comment what it is about.

Co-authored-by: Stjepan Glavina <stjepang@gmail.com>
  • Loading branch information
bors[bot] and Stjepan Glavina committed Dec 10, 2018
2 parents f1478c9 + 290735b commit a3252af
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions crossbeam-epoch/src/guard.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use core::fmt;
use core::mem;
use core::ptr;

use atomic::Shared;
use collector::Collector;
Expand Down Expand Up @@ -65,15 +64,6 @@ use internal::Local;
/// assert!(!epoch::is_pinned());
/// ```
///
/// The same can be achieved by cloning guards:
///
/// ```
/// use crossbeam_epoch as epoch;
///
/// let guard1 = epoch::pin();
/// let guard2 = guard1.clone();
/// ```
///
/// [`pin`]: fn.pin.html
pub struct Guard {
pub(crate) local: *const Local,
Expand Down Expand Up @@ -433,16 +423,6 @@ impl Drop for Guard {
}
}

impl Clone for Guard {
#[inline]
fn clone(&self) -> Guard {
match unsafe { self.local.as_ref() } {
None => Guard { local: ptr::null() },
Some(local) => local.pin(),
}
}
}

impl fmt::Debug for Guard {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.pad("Guard { .. }")
Expand Down

0 comments on commit a3252af

Please sign in to comment.