Lines Matching refs:a
15 It also allows in-place initialization of big `struct`s that would otherwise produce a stack
21 There are cases when you want to in-place initialize a struct. For example when it is very big
33 enabled and thus this feature can only be used with a nightly compiler. When enabling the
38 The feature is enabled by default, thus by default `pin-init` will require a nightly compiler.
47 and therefore a nightly compiler. Note that this feature is not enabled by default.
51 To initialize a `struct` with an in-place constructor you will need two things:
53 - a memory location that can hold your `struct` (this can be the [stack], an [`Arc<T>`],
58 - a custom function/macro returning an in-place constructor provided by someone else,
68 `../examples/mutex.rs`. It is essentially a userland rebuild of the `struct mutex` type from
69 the Linux kernel. It also uses a wait list and a basic spinlock. Importantly the wait list
70 requires it to be pinned to be locked and thus is a prime candidate for using this library.
75 `#[`[`pin_data`]`]`. It is a macro that uses `#[pin]` as a marker for
86 a: CMutex<usize>,
91 a <- CMutex::new(42),
97 (or just the stack) to actually initialize a `Foo`:
105 ### Using a custom function/macro that returns an initializer
107 Many types that use this library supply a function/macro that returns an initializer, because
137 [`pin_init_from_closure()`] comes in. This `unsafe` function allows you to create a
138 [`impl PinInit<T, E>`] directly from a closure. Of course you have to ensure that the closure
142 `slot` now contains a valid bit pattern for the type `T`,
189 // `slot` contains uninit memory, avoid creating a reference.
203 // All fields of `RawFoo` have been initialized, since `_p` is a ZST.
220 For more information on how to use [`pin_init_from_closure()`], take a look at the uses inside
221 the `kernel` crate. The [`sync`] module is a good starting point.