Skip to content
This repository has been archived by the owner on Jul 19, 2020. It is now read-only.

Add a then_with shim #35

Open
hgzimmerman opened this issue Dec 2, 2019 · 1 comment
Open

Add a then_with shim #35

hgzimmerman opened this issue Dec 2, 2019 · 1 comment

Comments

@hgzimmerman
Copy link
Member

There is currently a nightly feature for then and then_with functions on bools that allow them to be turned into Options using a provided value or closure.
This in conjunction with unwrap_or_default can be used to easily write "show this html or nothing" sections.

A stable shim trait for this could be added to this crate, have it live in experimental, and then remove it once the actual feature stabilizes.

https://doc.rust-lang.org/std/primitive.bool.html#method.then_with

@hgzimmerman
Copy link
Member Author

The naming has been renamed from then/then_with to then_some/then.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant