Closed RalfJung closed 4 years ago
That was about using offset_of!
, which is not possible with the existing API of rust-field-offset.
This PR is implementing the proposal a bit up that thread:
If there was a crate which implemented this macro: raw_address_of!((*ptr_to_undef).bar) and which guaranteed in the future to compile down to the MIR operator your RFC introduced, whilst for the moment making a "best effort" attempt, then I would be happy to use that to implement (2) in this crate.
Before making a release, let's see if the API works for @Diggsey
Sure
Yeah, I'd be happy to depend on this crate for the raw_field
function.
@RalfJung Does this macro resolve your concern here? https://github.com/Gilnaa/memoffset/pull/21#issuecomment-526351780
@Amanieu this macro has nothing to do with container_of!
. It just exposes something that we already did as part of offset_of!
before, so there is no change to what happens to provenance.
Expose the part of
offset_of!
that computes a raw pointer to a field as a separate macro. @Diggsey expressed that this would be interesting for their crate.If rust-field-offset could depend on memoffset to use this macro, that would mean there is just one place we have to change once
&raw
(or an equivalent mechanism) becomes stable, so that everyone uses the blessed way to do this.@Diggsey does this macro fit the needs of your crate? @Gilnaa are you okay with adding this to the API surface of
memoffset
?