Follow

Writing Rust is such a trap - I start out intending to not over-golf everything, but I always get too tempted to turn all my Option and Result wrangling into one-liners :( My latest sin is

`` `
let naive = NaiveDate::parse_from_str(date, "%Y-%m-%d");
naive
.ok()
.map(|date| TimeZone::from_local_date(&Local, &date).latest())
.expect("Override date should be valid YYYY-MM-DD")
```

· · Web · 0 · 0 · 0
Sign in to participate in the conversation
Mastodon

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!