chromium / subspace

A concept-centered standard library for C++20, enabling safer and more reliable products and a more modern feel for C++ code.; Also home of Subdoc the code-documentation generator.
https://suslib.cc
Apache License 2.0
89 stars 15 forks source link

Option<T&> from Option<T>& #389

Closed danakj closed 10 months ago

danakj commented 1 year ago

https://doc.rust-lang.org/stable/std/option/enum.Option.html#impl-From%3C%26'a+Option%3CT%3E%3E-for-Option%3C%26'a+T%3E

Option should support construction of an Option<T&> from an Option.

This is what as_ref() does, but supports going through into()

danakj commented 10 months ago

Actually, I don't think we should add this one.

Using into() to make a reference feels wrong without a borrow checker, as it's hiding the reference taking, and looks like a conversion to another value (which it is, but it's holding a reference).