Skip to content

Commit fbfee42

Browse files
committed
core: impl From<T> for Option<T>
1 parent fe5c439 commit fbfee42

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/libcore/option.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
use self::Option::*;
143143

144144
use clone::Clone;
145+
use convert::From;
145146
use default::Default;
146147
use iter::ExactSizeIterator;
147148
use iter::{Iterator, DoubleEndedIterator, FromIterator, IntoIterator};
@@ -754,6 +755,13 @@ impl<'a, T> IntoIterator for &'a mut Option<T> {
754755
}
755756
}
756757

758+
#[stable(since = "1.12.0", feature = "option_from")]
759+
impl<T> From<T> for Option<T> {
760+
fn from(val: T) -> Option<T> {
761+
Some(val)
762+
}
763+
}
764+
757765
/////////////////////////////////////////////////////////////////////////////
758766
// The Option Iterators
759767
/////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)