do_stuff(my_optional.value())
But people might not want to throw an exception, so
if (my_optional) do_stuff(*my_optional);
do_stuff(*my_optional)
I don't know rust so I suspect it has a language construct which c++ lacks that prevents you from doing
let Some(obj) = my_optional do_stuff(obj);
But people might not want to throw an exception, so
Must also be allowed. The consequence is someone can also just do No safety check is done and you get undefined behavior if the value is absent.I don't know rust so I suspect it has a language construct which c++ lacks that prevents you from doing