mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-30 13:51:13 +00:00
Add the #[pin] attribute to be able to project to the pinned item
This commit is contained in:
parent
9ed660926c
commit
f50a705e00
9 changed files with 32 additions and 16 deletions
|
@ -72,7 +72,7 @@ pub enum PinnedFlag {}
|
|||
|
||||
/// Type that can be used in the `Flag` parameter of `FieldOffset` to specify that
|
||||
/// This projection is valid on Pin types.
|
||||
type NotPinnedFlag = ();
|
||||
pub type NotPinnedFlag = ();
|
||||
|
||||
/// `fn` cannot appear dirrectly in a type that need to be const.
|
||||
/// Workaround that with an indiretion
|
||||
|
@ -244,6 +244,11 @@ impl<T, U, Flag> FieldOffset<T, U, Flag> {
|
|||
pub const unsafe fn as_pinned_projection(self) -> FieldOffset<T, U, PinnedFlag> {
|
||||
FieldOffset::new_from_offset_pinned(self.get_byte_offset())
|
||||
}
|
||||
|
||||
/// Remove the PinnedFlag
|
||||
pub const fn as_unpinned_projection(self) -> FieldOffset<T, U> {
|
||||
unsafe { FieldOffset::new_from_offset(self.get_byte_offset()) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, U> FieldOffset<T, U, PinnedFlag> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue