# then [![Crates.io Version](https://img.shields.io/crates/v/then.svg)](https://crates.io/crates/then) [![Docs.rs Latest](https://img.shields.io/badge/docs.rs-latest-blue.svg)](https://docs.rs/then) [![Build Status](https://img.shields.io/github/actions/workflow/status/rossmacarthur/advent/build.yaml?branch=trunk)](https://github.com/rossmacarthur/advent/actions/workflows/build.yaml?query=branch%3Atrunk) The standard library named `bool::then_some` and `bool::then` strangely. It should have been `then` and `then_with`. I find it annoying that `expr.then(|| value)` is shorter to type that the more “idiomatic” `expr.then_some(value)` This crate provides these functions under the following names `.some` and `.some_with`. ## Getting started First, add the crate to your Cargo manifest. ```sh cargo add then ``` Now bring the trait into scope. ```rust use then::Some; ``` The `.some` and `.some_with` methods are now available on `bool`. ```rust assert_eq!(false.some(0), None); assert_eq!(true.some_with(Default::default), Some(0)); ``` ## License This project is distributed under the terms of both the MIT license and the Apache License (Version 2.0). See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT) for details.