Github Add Option::get_or_default by camsteffen · Pull Request #82849 · rust-lan...
source link: https://github.com/rust-lang/rust/pull/82849
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.
Tracking issue: #82901
The original issue is #55042, which was closed, but for an invalid reason (see discussion there). Opening this to reconsider (I hope that's okay). It seems like the only gap for Option
being "entry-like".
I ran into a need for this method where I had a Vec<Option<MyData>>
and wanted to do vec[n].get_or_default().my_data_method()
. Using an Option
as an inner component of a data structure is probably where the need for this will normally arise.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK