Lines Matching full:foo
78 struct Foo {
84 let foo = pin_init!(Foo {
90 `foo` now is of the type [`impl PinInit<Foo>`]. We can now use any smart pointer that we like
91 (or just the stack) to actually initialize a `Foo`:
94 let foo: Result<Pin<Box<Foo>>, AllocError> = Box::pin_init(foo);
153 pub struct foo {
157 pub fn init_foo(ptr: *mut foo);
158 pub fn destroy_foo(ptr: *mut foo);
160 pub fn enable_foo(ptr: *mut foo, flags: u32) -> i32;
166 /// `foo` is always initialized
172 foo: UnsafeCell<MaybeUninit<bindings::foo>>,
179 // enabled `foo`,
184 let foo = addr_of_mut!((*slot).foo);
185 let foo = UnsafeCell::raw_get(foo).cast::<bindings::foo>();
187 // Initialize the `foo`
188 bindings::init_foo(foo);
191 let err = bindings::enable_foo(foo, flags);
193 // Enabling has failed, first clean up the foo and then return the error.
194 bindings::destroy_foo(foo);
208 // SAFETY: Since `foo` is initialized, destroying is safe.
209 unsafe { bindings::destroy_foo(self.foo.get().cast::<bindings::foo>()) };
223 [`impl PinInit<Foo>`]: https://docs.rs/pin-init/latest/pin_init/trait.PinInit.html