You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the code I'm writing, it would be useful to have Default on WeakPtr so I don't need to wrap it in an extra layer of Option. This would make it more like std::rc::Weak and I think presents no problem because the null pointer is valid.
Happy to send a PR, I'm filing as an issue first to verify that it would be wanted, and in case there's a problem with the idea I'm missing.
The text was updated successfully, but these errors were encountered:
alloc::rc::Weak is actually core::ptr::NonNull internally - they use dangling pointers to create a Default implementation.
But yeah, WeakPtr could probably have a Default impl of WeakPtr::new(core::ptr::null_mut()), but I don't think we want this, since load would now return null in two cases: If the object was deallocated or if it was created from a null pointer - that is, you can't distinguish these two cases, which makes for a bad API IMO.
In the code I'm writing, it would be useful to have
Default
onWeakPtr
so I don't need to wrap it in an extra layer ofOption
. This would make it more like std::rc::Weak and I think presents no problem because the null pointer is valid.Happy to send a PR, I'm filing as an issue first to verify that it would be wanted, and in case there's a problem with the idea I'm missing.
The text was updated successfully, but these errors were encountered: