Feature Request: Convert option-types to pointers

The pointer primitive has

unsafe fn as_ref<'a>(self) -> Option<&'a T>;

but the converse doesn’t seem to exist

fn from_ref(Option<&T>) -> *const T;

but I think it should. :slight_smile: Not sure what module it’d go in, though - std::ptr?

Is this even where feature requests go?

3 Likes

There’s some previous discussion in this rfc issue

At least for now I suggest you write an extension trait for Option and put your method in there. That way you don’t need to care about stdlib, and you still get nice method syntax.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.