Skip to content

Commit ef519c1

Browse files
committed
Add a implementation of From for converting &'a Option<T> into
`Option<&'a T>`
1 parent 76b69a6 commit ef519c1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/libcore/option.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,12 @@ impl<T> From<T> for Option<T> {
10641064
}
10651065
}
10661066

1067+
impl<'a, T> From<&'a Option<T>> for Option<&'a T> {
1068+
fn from(o: &'a Option<T>) -> Option<&'a T> {
1069+
o.as_ref()
1070+
}
1071+
}
1072+
10671073
/////////////////////////////////////////////////////////////////////////////
10681074
// The Option Iterators
10691075
/////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)