-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Amend 0809 to reduce the number of traits.
Use the following trait structure: unsafe trait Placer<Data: ?Sized> { type Place: Place<Data>; fn make_place(&mut self) -> Self::Place; } unsafe trait Boxer<Data: ?Sized>: Sized { type Place: Place<Data, Owner=Self>; fn make_place() -> Self::Place; } trait Place<Data: ?Sized> { type Owner; fn pointer(&mut self) -> *mut Data; unsafe fn finalize(self) -> Self::Owner; } The key differences are: 1. The `Placer` and `Boxer` traits must be unsafe because the compiler will blindly write to the pointers returned by `Placer::make_place(self).pointer()` and `Boxer::make_place().pointer()`. Note: we could have made `Place` itself unsafe but, if we ever decide to eventually support DST placement new, the `DstBoxer` and `DstPlacer` traits would need to be unsafe so there's no point in making Place unsafe. 2. Merge `InPlace` into `Place`. 3. Make the boxing side of the hierarchy mirror the "in (PLACE)" side of hierarchy.
- Loading branch information
Showing
1 changed file
with
83 additions
and
109 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