Crate projecture
source · [−]Expand description
Projecture
This is in a proof of concept state and also internally uses a lot of not yet battle-tested unsafe code so use it on your own risk meanwhile if you are good with unsafe rust i would appreciate a soundness review
Allows to do an arbitrary projections without procedural macros, and as such does not have additional requirements on target struct, so in comparison to other crates that do similar things if target struct is located in external crate that crate does not have to explicitly add a support such projection.
Although as of now this crate has a one serious drawback - it can’t support enums.
Currently can do following type of projections
- Destructuring projection (more powerful then what you can do in standard rust with regular
let <pattern>
) - Reference projection (more powerful then what you can do in standard rust with regular
let <pattern>
) - Mutable reference projection (more powerful then what you can do in standard rust with regular
let <pattern>
) - Pin projection
- Cell projection
- MaybeUninit projection
See project
! macro for usage examples.
Also allows dependent crates to define their own projections via traits.
MSRV: 1.51
Macros
Structs
Transparent wrapper to indicate that a type should not be pin projected. It will not be p
Traits
Implement this if there is a user-defined field wrapper type
Implement that if you need to do some kind of post processing
Implement this on your reference type that you want to work with this crate (like Pin
or std::cell:Ref
)
for Pin projection to work soundly if struct wants to implement custom Drop it needs to
always go through Pin<&mut Self>
. So Drop
implementation must directly delegate to PinDrop
.
You can use pin_drop
macro to do that without unsafe
Trait to get raw pointer to underlying struct
Trait to wrap raw pointer to a field with a type that corresponds to a projection being done
Implement this if your type can be unwrapped on a dereference operation when doing destructuring projection