From ef519c1de54e6d833d05bac7c4ce290ae54e82dc Mon Sep 17 00:00:00 2001 From: Georg Semmler Date: Thu, 9 Aug 2018 11:02:08 +0200 Subject: [PATCH] Add a implementation of `From` for converting `&'a Option` into `Option<&'a T>` --- src/libcore/option.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 2b6c376f8a7..ad69d137685 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -1064,6 +1064,12 @@ impl From for Option { } } +impl<'a, T> From<&'a Option> for Option<&'a T> { + fn from(o: &'a Option) -> Option<&'a T> { + o.as_ref() + } +} + ///////////////////////////////////////////////////////////////////////////// // The Option Iterators /////////////////////////////////////////////////////////////////////////////