Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing AllocRef for actual references #34

Open
oliver-giersch opened this issue Dec 20, 2019 · 0 comments
Open

Implementing AllocRef for actual references #34

oliver-giersch opened this issue Dec 20, 2019 · 0 comments

Comments

@oliver-giersch
Copy link

From what I can gather from the currently proposed API design, the way the associated types are set up between the traits BuildAllocRef, DeallocRef and AllocRef it would be impossible to implement the latter two for an actual reference as in e.g. impl<'a> AllocRef for &'a CustomAllocator.
If I am not mistaken, this means that &'a CustomAllocator must also implement DeallocRef and needs an associated builder type. However, without GAT it is not possible to implement BuildAllocRef for CustomAllocator and define &'a CustomAllocator as the associated Ref type.

Is my understanding of the intended usage for these traits correct or am I wrong somehow? Furthermore, even if GAT were available and BuildAllocRef were defined as:

pub trait BuildAllocRef {
    type Ref<'a>: DeallocRef + 'a;

    unsafe fn build_alloc_ref<'a>(
        &'a mut self,
        ptr: NonNull<u8>,
        layout: Option<NonZeroLayout>
    ) -> Self::Ref<'a>;
}

This would result in DeallocRef/AllocRef being impossible to implement for any owning handles (like Arc) or ZST handles, since built Ref would be required to be bound to the lifetime of the builder, at least if I understand the proposed GAT RFC correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant