Skip to content

AsRef for "implements this COM interface"? #571

Closed
@SimonSapin

Description

@SimonSapin

I’d like to write generic code that accepts any type that implements the IUnknown interface (in order to call Release() in Drop). I started with T: Deref<Target=IUnknown>, but then some winapi types only deference indirectly to IUnknown.

What do you think of implementing the AsRef trait (in addition to Deref) to represent the "implements a COM interface" relationship? For example IDXGIDevice would have both AsRef<IDXGIObject> and AsRef<IUnknown> (in addition to Deref<Target=IDXGIObject> that it already has). (The body of all these impls could be just self, since auto-deref is recursive.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions