When you call Option::map() it creates copy of the object that
Option is wrapping. So if you take a reference of that you're
getting a reference to a temporary object. Calling Option::as_ref()
gives you an Option<&T>, i.e. a reference directly to the object
contained in the Option, and when you call .map() on that it makes
a copy of the reference, which doesn't introduce a temporary.
When you call Option::map() it creates copy of the object that
Option is wrapping. So if you take a reference of that you're
getting a reference to a temporary object. Calling Option::as_ref()
gives you an Option<&T>, i.e. a reference directly to the object
contained in the Option, and when you call .map() on that it makes
a copy of the reference, which doesn't introduce a temporary.