-
Notifications
You must be signed in to change notification settings - Fork 14
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
Provide easy way to retain-construct from a reference #20
Comments
Something like |
Yep! |
@retep998 @Manishearth if need change RefCount, we could call clone() or Release() explicitly
This is common to store pointer in WndExtraMemtory, and to retrieve, as raw pointer, ComPtr::new(p), |
I mean yes, there are many ways to make it work, but in this case adopt/retain semantics are a common difference and I think it would be good for documentation, even, to have both as first class APIs that are well documented. |
Currently
ComPtr::from_raw
adopts the given pointer, which means that it assumes that it has already been addreffed.This isn't always true, though, sometimes you want to retain the refcount of the old pointer, which you're simply borrowing from to create a new reference. We should have a separate constructor for this, the current way of doing it is to
mem::forget(ptr.clone())
which is clunky.The text was updated successfully, but these errors were encountered: