Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR does three things:
fn replace_with()
&fn replace_with_or_default()
available on both stable and nightly Rust withno_std
.fn replace_with_or_abort()
available on nightly Rust withno_std
via"nightly"
feature.unsafe fn replace_with_or_abort_unchecked()
available via"panic_abort"
feature.The latter expects
panic = "abort"
to be defined inCargo.toml
. Being hidden behind a feature flag it will also be hidden on docs.rs (afaik), which I would consider desirable, actually. It's a "last resort" escape hatch, not an API one would want to get into everybody's hands, without knowing the issues around unwinding.I chose the
unsafe fn …_unchecked()
naming pattern, as it's a quite common pattern already.