-
Notifications
You must be signed in to change notification settings - Fork 109
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
Make unsync::Lazy<T, F>
covariant in F
#233
Make unsync::Lazy<T, F>
covariant in F
#233
Conversation
a48ae40
to
42cf6ae
Compare
42cf6ae
to
179b2a9
Compare
unsync::Lazy<T, F>
covariantunsync::Lazy<T, F>
covariant in F
state: Cell<State>, | ||
data: Data<T, F>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that we could make Lazy
even more compact by moving state
at the beginning of each union variant (and making the union
be #[repr(C)]
).
- If
T = [u8; 3]
, andF = u16
, this would makeLazy<T, F>
be4 bytes
rather than6
, for instance.
#[repr(C)] struct InOrder<T, U>(T, U);
#[repr(C)]
union Lazy<T, F = fn() -> T> {
init: MD<InOrder< Cell<State>, F >>,
value: MD<InOrder< Cell<State>, UC<T> >>,
// convenience variant to keep the code symmetric.
state: MD<InOrder< Cell<State>, () >>,
}
bors r+ Thanks! |
Build succeeded! The publicly hosted instance of bors-ng is deprecated and will go away soon. If you want to self-host your own instance, instructions are here. If you want to switch to GitHub's built-in merge queue, visit their help page. |
Ah, I think this doesn't actually work as we want it too 😭 I think we've lost dropchk here, no? Before, we didn't have a custom drop, so a In this variation, we now have a custom drop, so that won't be allowed. There's a dropchk test for OnceCell, but not for lazy. Is there some way to have |
Oh, good thing this wasn't released!
Short answer is no; slightly longer answer is the post you've linked to, but which generalizes with great difficulty (it's very situation-specific) Even longer answer, which I was planning to write a crate and blog post about it, is that with HKTs/GATs it is possible to define an advanced API that would let people opt-into their specific usage So for
Conclusion (to share back to #167): blocked due to lack of I'm submitting a revert as we speak (my latest PR on the topic), and I apologize for the inconvenience, @matklad; I reckon it must have been quite a spam of notifications on your end, for a niche thing, and which hasn't panned out |
"Continuation" from #230, which partially handles #167.
unsync::Lazy
smaller in size in most cases, sinceT
andF
are now sharing the sameunion
storage.The
sync
can basically use the same logic (my PR paves the way for such a follow-up PR), only the whole thing would need to be moved to each of the possibleimp
lementations ofsync::OnceCell
, and special care to synchronization semantics will be in order, which I prefer to let somebody else do.