-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #458 - JustForFun88:simplify-clone, r=Amanieu
Simplify `Clone` by removing redundant guards These extra guards only complicate the code where it is not needed anyway. The `Drop` function checks the number of `items` in a table before dropping elements (see below), so that dropping the uninitialize table as well as table with no actual data (but with `FULL` control bytes) is safe . Added tests to check that the current behavior of `Drop` won't change in the future. ```rust impl<T, A: Allocator + Clone> Drop for RawTable<T, A> { fn drop(&mut self) { if !self.table.is_empty_singleton() { unsafe { self.drop_elements(); self.free_buckets(); } } } } impl<T, A: Allocator + Clone> RawTable<T, A> { unsafe fn drop_elements(&mut self) { if Self::DATA_NEEDS_DROP && !self.is_empty() { for item in self.iter() { item.drop(); } } } } ```
- Loading branch information
Showing
3 changed files
with
227 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters