Lines Matching full:foo
96 struct Foo {
102 let foo = pin_init!(Foo {
108 `foo` now is of the type [`impl PinInit<Foo>`]. We can now use any smart pointer that we like
109 (or just the stack) to actually initialize a `Foo`:
112 let foo: Result<Pin<Box<Foo>>, AllocError> = Box::pin_init(foo);
170 pub struct foo {
174 pub fn init_foo(ptr: *mut foo);
175 pub fn destroy_foo(ptr: *mut foo);
177 pub fn enable_foo(ptr: *mut foo, flags: u32) -> i32;
183 /// `foo` is always initialized
189 foo: UnsafeCell<MaybeUninit<bindings::foo>>,
196 // enabled `foo`,
201 let foo = &raw mut (*slot).foo;
202 let foo = UnsafeCell::raw_get(foo).cast::<bindings::foo>();
204 // Initialize the `foo`
205 bindings::init_foo(foo);
208 let err = bindings::enable_foo(foo, flags);
210 // Enabling has failed, first clean up the foo and then return the error.
211 bindings::destroy_foo(foo);
225 // SAFETY: Since `foo` is initialized, destroying is safe.
226 unsafe { bindings::destroy_foo(self.foo.get().cast::<bindings::foo>()) };
238 [`impl PinInit<Foo>`]: https://docs.rs/pin-init/latest/pin_init/trait.PinInit.html