Conversation
This allows one to use ErasedPtr where rust won't allow a typed reference. For example in recursive types.
* remove references of the unerased value * fix memory leaks in tests by unerase/drop the erased values
- using scopeguard to write the pointer back into its original place - correct the ManuallyDrop() to wrap the actual value and take it out in the scopeguard
This changes ErasedPtr from type alias to a newtype implementation. Thus ErasedPtr implements few methods now: * `as_unit_ptr(&self) -> *const ()` getting the pointer value for diagnostics. * `with(FnOnce(&E)-> T)` and `with_mut(FnOnce(&E)-> T)` are moved from the Eraseable trait to ErasedPtr.
d3b40c7 to
69f7b48
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I anticipate the change from the type alias to a newtype implementation here. Maybe this qualifies/requires a major version bump (I suspect this is still binary compatible as its a transparent repr).
A possible alternative would be to implement 'with()/with_mut()' functions as toplevel crate functions (I wont necessary like that, but ymmv). Keeping them in the Erasable trait won't be totally bad as well.