Skip to content

Dev/result #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Dev/result #62

wants to merge 2 commits into from

Conversation

y86-dev
Copy link
Member

@y86-dev y86-dev commented May 28, 2025

  • change blanket impls of Init and PinInit from impl<T, E> [Pin]Init<T, E> for E to impl<T> [Pin]Init<T> for T
  • add impl<T, E> [Pin]Init<T, E> for Result<T, E>, so results are now (pin-)initializers

The inner SAFETY comments were missing since commit 5cfe7be ("rust:
enable `clippy::undocumented_unsafe_blocks` lint").

Also rework the implementation of `__pinned_init` to better justify the
SAFETY comment.

Signed-off-by: Benno Lossin <[email protected]>
@y86-dev y86-dev force-pushed the dev/result branch 2 times, most recently from 925f1bf to 1624dea Compare May 29, 2025 07:55
Remove the error from the blanket implementations `impl<T, E> Init<T, E>
for T` (and also for `PinInit`). Add implementations for `Result<T, E>`.

This allows one to easily construct (un)conditional failing
initializers. It also improves the compatibility with APIs that do not
use pin-init, because users can supply a `Result<T, E>` to a  function
taking an `impl PinInit<T, E>`.

Suggested-by: Alice Ryhl <[email protected]>
Signed-off-by: Benno Lossin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant