6

Mark `Option::insert` as must_use by oxalica · Pull Request #87196 · rust-lang/r...

 3 years ago
source link: https://github.com/rust-lang/rust/pull/87196
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Copy link

Contributor

the8472 commented 7 days ago

must_use seems to be used (hah) somewhat inconsistently. Most methods annotated with it indicate an outright programming error, e.g. ignoring results which likely indicate error states, lazy iterators or integer methods where the original isn't modified.

This on the other hand is merely a style thing where a method that expresses the intent better is available. But it isn't without precedent, e.g. mem::replace is annotated like that too.

But if this is added, then should Option::take (as = None) and Option::replace (similar to insert) be annotated too?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK