Skip to content

Commit

Permalink
Auto merge of #237 - cole-miller:raw-table-default, r=Amanieu
Browse files Browse the repository at this point in the history
Implement `Default` for `RawTable`

This seems straightforward and useful. (I found myself wanting it so I could use `core::mem::take` on a `RawTable` field.) Hopefully I'm not missing something.
  • Loading branch information
bors committed Feb 14, 2021
2 parents b5b5be8 + f9a46e5 commit 80b2c31
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## Added
- Added safe `try_insert_no_grow` method to `RawTable`. (#229)
- Implemented `Default` for `RawTable`. (#237)

## Changed
- The minimum Rust version has been bumped to 1.49.0. (#230)
Expand Down
7 changes: 7 additions & 0 deletions src/raw/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1587,6 +1587,13 @@ impl<T: Clone, A: Allocator + Clone> RawTable<T, A> {
}
}

impl<T, A: Allocator + Clone + Default> Default for RawTable<T, A> {
#[cfg_attr(feature = "inline-more", inline)]
fn default() -> Self {
Self::new_in(Default::default())
}
}

#[cfg(feature = "nightly")]
unsafe impl<#[may_dangle] T, A: Allocator + Clone> Drop for RawTable<T, A> {
#[cfg_attr(feature = "inline-more", inline)]
Expand Down

0 comments on commit 80b2c31

Please sign in to comment.