Skip to content

Commit

Permalink
Use mem::take instead of mem::replace with default
Browse files Browse the repository at this point in the history
  • Loading branch information
czipperz committed Jul 2, 2019
1 parent 99abdfa commit 8a3797b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/libcore/option.rs
Expand Up @@ -845,7 +845,7 @@ impl<T> Option<T> {
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn take(&mut self) -> Option<T> {
mem::replace(self, None)
mem::take(self)
}

/// Replaces the actual value in the option by the value given in parameter,
Expand Down
2 changes: 1 addition & 1 deletion src/libproc_macro/bridge/buffer.rs
Expand Up @@ -78,7 +78,7 @@ impl<T: Copy> Buffer<T> {
}

pub(super) fn take(&mut self) -> Self {
mem::replace(self, Self::default())
mem::take(self)
}

pub(super) fn extend_from_slice(&mut self, xs: &[T]) {
Expand Down

0 comments on commit 8a3797b

Please sign in to comment.