Function toad_common::fns::const_
source · pub fn const_<T, R>(r: R) -> impl FnOnce(T) -> R
Expand description
Returns a function that discards its argument and always returns r
.
use toad_common::*;
fn try_get_string() -> Result<String, std::io::Error> {
}
fn do_stuff() -> Result<String, std::io::Error> {
try_get_string().map(const_("it worked!".to_string())) // equivalent to:
.map(|_| "it worked!".to_string())
}