Skip to content

Commit

Permalink
rust: init: add initialization macros
Browse files Browse the repository at this point in the history
Add the following initializer macros:
- `#[pin_data]` to annotate structurally pinned fields of structs,
  needed for `pin_init!` and `try_pin_init!` to select the correct
  initializer of fields.
- `pin_init!` create a pin-initializer for a struct with the
  `Infallible` error type.
- `try_pin_init!` create a pin-initializer for a struct with a custom
  error type (`kernel::error::Error` is the default).
- `init!` create an in-place-initializer for a struct with the
  `Infallible` error type.
- `try_init!` create an in-place-initializer for a struct with a custom
  error type (`kernel::error::Error` is the default).

Also add their needed internal helper traits and structs.

Co-developed-by: Gary Guo <[email protected]>
Signed-off-by: Gary Guo <[email protected]>
Signed-off-by: Benno Lossin <[email protected]>
Reviewed-by: Alice Ryhl <[email protected]>
Reviewed-by: Andreas Hindborg <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[ Fixed three typos. ]
Signed-off-by: Miguel Ojeda <[email protected]>
  • Loading branch information
Benno Lossin authored and ojeda committed Apr 12, 2023
1 parent 90e53c5 commit fc6c6ba
Show file tree
Hide file tree
Showing 6 changed files with 1,747 additions and 7 deletions.
Loading

0 comments on commit fc6c6ba

Please sign in to comment.