-
Notifications
You must be signed in to change notification settings - Fork 49
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
Id improvements #21
Merged
Merged
Id improvements #21
Conversation
This file contains 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
This was referenced Sep 5, 2021
Closed
madsmtm
force-pushed
the
id-improvements
branch
from
September 8, 2021 14:44
739a4ed
to
41170ef
Compare
These names are shorter and more pretty clearly signifies the intention. We also now take `NonNull` arguments so that there's less stuff we have to verify.
- Eq - PartialOrd - Ord - Display - Iterator - DoubleEndedIterator - ExactSizeIterator - FusedIterator - Borrow - BorrowMut - AsRef - AsMut - Unpin
Because I want to get rid of objc2::rc::WeakPtr. WeakId can now also use the null-pointer optimization, and it has a Default implementation.
madsmtm
force-pushed
the
id-improvements
branch
2 times, most recently
from
September 9, 2021 10:46
e7ffccb
to
e36b8de
Compare
Will allow us to do some nice things when/if GATs stabilize
madsmtm
force-pushed
the
id-improvements
branch
from
September 9, 2021 10:50
e36b8de
to
f41363e
Compare
Id is such a vital requirement for applications that there's no need to make it a "second class citizen". If we really feel it's too much of an experiment, we can always feature-flag it later. Also, there's might be traits I'd like to implement for e.g. Option<Id> that is not possible if it lives in it's own crate!
We want to encourage users to use Id and WeakId, because they provide much stronger guarantees. The other types can in most cases be emulated as: type StrongPtr = Option<Id<Object, Shared>> type WeakPtr = WeakId<Object> And for the cases where they can't, their implementation is pretty simple anyhow, so advanced users can just use objc2_sys to implement the functionality they need themselves.
This is a usability degradation, but before we know more about actual usage patterns this is the safer option; users will have to explicitly specify the ownership they're expecting. See SSheldon/rust-objc-id#4
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.
Replaces upstream SSheldon/rust-objc#98 and SSheldon/rust-objc#95.
We want to avoid having users specify their own
X
+XRef
types. Instead they should useId<X>
+&X
.TODO:
Ownership
trait should be sealed.Restrict to onlyIt was already restricted toMessage
/"ObjectType"
/ "RetainAble
" types?Message
, the rest is postponed.UnsafeCell
is appropriate.&'pool mut X
->Id<X, Owned>
?&'pool X
->Id<X, Shared>
?&X
->Id<X, Shared>
?&X
could come fromId<X, Owned>
, since lifetime information is discarded!Consider adding lifetime info toPostponed to investigation in Fix ownership inId
, see above.objc2-foundation
#29.X
is actuallySized
? IsId<X, O>
even valid?frutiy
'sNSString
hackRenamePostponed, this seems overly disruptive, just for disruptiveness' sake.Id
->Retain
/Retained
/...Id::autorelease
Make this work different "backends" likeFuture.block
,libdispatch
, CoreFoundation; seefruity
's approach.AddNot desired onretain_count
function.Id
, this should instead be available on all objects.References:
fruity::core::Arc
fruity::core::ObjectType
fruity::objc::ObjcObject