Mastodon Feed: Post

Mastodon Feed

Boosted by rust@mas.to ("Rust tips"):
shanecelis@mastodon.gamedev.place ("Shane Celis") wrote:

#rustlang tip: Option is practically useless because then you have to specify what type of None you're providing but you can get something almost as expressive.

// Sucks. You can't provide None without saying what you're giving none // of, e.g., cls(None::<usize>). fn cls(color: Option<impl Into<!-- raw HTML omitted -->>) { ... } // Instead implement one From<Option<>> for your type then you can use // None plainly, e.g. cls(None). fn cls(color: impl Into<!-- raw HTML omitted -->) { ... }