mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-30 13:51:13 +00:00
Some doc polish
This commit is contained in:
parent
14fe897086
commit
697aa61a0c
3 changed files with 26 additions and 18 deletions
|
@ -67,7 +67,7 @@ assert_eq!(FOO.get_byte_offset(), 4);
|
||||||
)]
|
)]
|
||||||
/**
|
/**
|
||||||
|
|
||||||
## limitations
|
## Limitations
|
||||||
|
|
||||||
Only work with named #[repr(C)] structures.
|
Only work with named #[repr(C)] structures.
|
||||||
|
|
||||||
|
@ -95,23 +95,6 @@ let pin_box = Box::pin(Foo{field_1: 1, field_2: 2});
|
||||||
assert_eq!(*FIELD_2.apply_pin(pin_box.as_ref()), 2);
|
assert_eq!(*FIELD_2.apply_pin(pin_box.as_ref()), 2);
|
||||||
```
|
```
|
||||||
|
|
||||||
### `const-field-offset`
|
|
||||||
|
|
||||||
In case the `const-field-offset` crate is re-exported, it is possible to
|
|
||||||
specify the crate name using the `const_field_offset` attribute.
|
|
||||||
|
|
||||||
```rust
|
|
||||||
// suppose you re-export the const_field_offset create from a different module
|
|
||||||
mod xxx { pub use const_field_offset as cfo; }
|
|
||||||
#[repr(C)]
|
|
||||||
#[derive(xxx::cfo::FieldOffsets)]
|
|
||||||
#[const_field_offset(xxx::cfo)]
|
|
||||||
struct Foo {
|
|
||||||
field_1 : u8,
|
|
||||||
field_2 : u32,
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
### `pin_drop`
|
### `pin_drop`
|
||||||
|
|
||||||
This attribute works like the `pin` attribute but it does not prevent a custom
|
This attribute works like the `pin` attribute but it does not prevent a custom
|
||||||
|
@ -138,6 +121,23 @@ impl PinnedDrop for Foo {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### `const-field-offset`
|
||||||
|
|
||||||
|
In case the `const-field-offset` crate is re-exported, it is possible to
|
||||||
|
specify the crate name using the `const_field_offset` attribute.
|
||||||
|
|
||||||
|
```rust
|
||||||
|
// suppose you re-export the const_field_offset create from a different module
|
||||||
|
mod xxx { pub use const_field_offset as cfo; }
|
||||||
|
#[repr(C)]
|
||||||
|
#[derive(xxx::cfo::FieldOffsets)]
|
||||||
|
#[const_field_offset(xxx::cfo)]
|
||||||
|
struct Foo {
|
||||||
|
field_1 : u8,
|
||||||
|
field_2 : u32,
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
*/
|
*/
|
||||||
#[proc_macro_derive(FieldOffsets, attributes(const_field_offset, pin, pin_drop))]
|
#[proc_macro_derive(FieldOffsets, attributes(const_field_offset, pin, pin_drop))]
|
||||||
pub fn const_field_offset(input: TokenStream) -> TokenStream {
|
pub fn const_field_offset(input: TokenStream) -> TokenStream {
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
/*!
|
||||||
|
This crate expose the `FieldOffsets` derive macro, and the required.
|
||||||
|
|
||||||
|
It allows to get const FieldOffset for member of a `#[repr(C)]` struct.
|
||||||
|
|
||||||
|
The `FieldOffset` type is re-exported from the `field-offset` crate.
|
||||||
|
*/
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -64,6 +64,7 @@ that `cbindgen` can see the actual vtable.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#[doc(no_inline)]
|
||||||
pub use const_field_offset::*;
|
pub use const_field_offset::*;
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
use core::ops::{Deref, DerefMut, Drop};
|
use core::ops::{Deref, DerefMut, Drop};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue