Lines Matching full:foo

42 //! struct Foo {
48 //! let foo = pin_init!(Foo {
49 //! a <- new_mutex!(42, "Foo::a"),
54 //! `foo` now is of the type [`impl PinInit<Foo>`]. We can now use any smart pointer that we like
55 //! (or just the stack) to actually initialize a `Foo`:
62 //! # struct Foo {
67 //! # let foo = pin_init!(Foo {
68 //! # a <- new_mutex!(42, "Foo::a"),
71 //! let foo: Result<Pin<Box<Foo>>> = Box::pin_init(foo);
128 //! # pub struct foo;
129 //! # pub unsafe fn init_foo(_ptr: *mut foo) {}
130 //! # pub unsafe fn destroy_foo(_ptr: *mut foo) {}
131 //! # pub unsafe fn enable_foo(_ptr: *mut foo, _flags: u32) -> i32 { 0 }
143 //! /// `foo` is always initialized
147 //! foo: Opaque<bindings::foo>,
156 //! // enabled `foo`,
161 //! let foo = addr_of_mut!((*slot).foo);
163 //! // Initialize the `foo`
164 //! bindings::init_foo(Opaque::raw_get(foo));
167 //! let err = bindings::enable_foo(Opaque::raw_get(foo), flags);
169 //! // Enabling has failed, first clean up the foo and then return the error.
170 //! bindings::destroy_foo(Opaque::raw_get(foo));
184 //! // SAFETY: Since `foo` is initialized, destroying is safe.
185 //! unsafe { bindings::destroy_foo(self.foo.get()) };
204 //! [`impl PinInit<Foo>`]: PinInit
243 /// struct Foo {
254 /// stack_pin_init!(let foo = pin_init!(Foo {
260 /// let foo: Pin<&mut Foo> = foo;
261 /// pr_info!("a: {}", &*foo.a.lock());
296 /// struct Foo {
306 /// stack_try_pin_init!(let foo: Result<Pin<&mut Foo>, AllocError> = pin_init!(Foo {
312 /// let foo = foo.unwrap();
313 /// pr_info!("a: {}", &*foo.a.lock());
322 /// struct Foo {
332 /// stack_try_pin_init!(let foo: Pin<&mut Foo> =? pin_init!(Foo {
338 /// pr_info!("a: {}", &*foo.a.lock());
373 /// struct Foo {
383 /// # fn demo() -> impl PinInit<Foo> {
386 /// let initializer = pin_init!(Foo {
418 /// # struct Foo {
426 /// impl Foo {
438 /// Users of `Foo` can now create it like this:
445 /// # struct Foo {
453 /// # impl Foo {
463 /// let foo = Box::pin_init(Foo::new());
473 /// # struct Foo {
481 /// # impl Foo {
494 /// foo1: Foo,
496 /// foo2: Foo,
503 /// foo1 <- Foo::new(),
504 /// foo2 <- Foo::new(),
796 /// struct Foo {
801 /// impl Foo {
803 /// pr_info!("Setting up foo");
807 /// let foo = pin_init!(Foo {
813 /// }).pin_chain(|foo| {
814 /// foo.setup();
903 /// struct Foo {
907 /// impl Foo {
909 /// pr_info!("Setting up foo");
913 /// let foo = init!(Foo {
915 /// }).chain(|foo| {
916 /// foo.setup();
1224 /// struct Foo {
1230 /// impl PinnedDrop for Foo {
1232 /// pr_info!("Foo is being dropped!");