|
150 | 150 | use crate::iter::{FromIterator, FusedIterator, TrustedLen};
|
151 | 151 | use crate::pin::Pin;
|
152 | 152 | use crate::{
|
153 |
| - fmt, hint, mem, |
| 153 | + hint, mem, |
154 | 154 | ops::{self, Deref, DerefMut},
|
155 | 155 | };
|
156 | 156 |
|
@@ -1121,90 +1121,6 @@ impl<T: Clone> Option<&mut T> {
|
1121 | 1121 | }
|
1122 | 1122 | }
|
1123 | 1123 |
|
1124 |
| -impl<T: fmt::Debug> Option<T> { |
1125 |
| - /// Consumes `self` while expecting [`None`] and returning nothing. |
1126 |
| - /// |
1127 |
| - /// # Panics |
1128 |
| - /// |
1129 |
| - /// Panics if the value is a [`Some`], with a panic message including the |
1130 |
| - /// passed message, and the content of the [`Some`]. |
1131 |
| - /// |
1132 |
| - /// # Examples |
1133 |
| - /// |
1134 |
| - /// ``` |
1135 |
| - /// #![feature(option_expect_none)] |
1136 |
| - /// |
1137 |
| - /// use std::collections::HashMap; |
1138 |
| - /// let mut squares = HashMap::new(); |
1139 |
| - /// for i in -10..=10 { |
1140 |
| - /// // This will not panic, since all keys are unique. |
1141 |
| - /// squares.insert(i, i * i).expect_none("duplicate key"); |
1142 |
| - /// } |
1143 |
| - /// ``` |
1144 |
| - /// |
1145 |
| - /// ```should_panic |
1146 |
| - /// #![feature(option_expect_none)] |
1147 |
| - /// |
1148 |
| - /// use std::collections::HashMap; |
1149 |
| - /// let mut sqrts = HashMap::new(); |
1150 |
| - /// for i in -10..=10 { |
1151 |
| - /// // This will panic, since both negative and positive `i` will |
1152 |
| - /// // insert the same `i * i` key, returning the old `Some(i)`. |
1153 |
| - /// sqrts.insert(i * i, i).expect_none("duplicate key"); |
1154 |
| - /// } |
1155 |
| - /// ``` |
1156 |
| - #[inline] |
1157 |
| - #[track_caller] |
1158 |
| - #[unstable(feature = "option_expect_none", reason = "newly added", issue = "62633")] |
1159 |
| - pub fn expect_none(self, msg: &str) { |
1160 |
| - if let Some(val) = self { |
1161 |
| - expect_none_failed(msg, &val); |
1162 |
| - } |
1163 |
| - } |
1164 |
| - |
1165 |
| - /// Consumes `self` while expecting [`None`] and returning nothing. |
1166 |
| - /// |
1167 |
| - /// # Panics |
1168 |
| - /// |
1169 |
| - /// Panics if the value is a [`Some`], with a custom panic message provided |
1170 |
| - /// by the [`Some`]'s value. |
1171 |
| - /// |
1172 |
| - /// [`Some(v)`]: Some |
1173 |
| - /// |
1174 |
| - /// # Examples |
1175 |
| - /// |
1176 |
| - /// ``` |
1177 |
| - /// #![feature(option_unwrap_none)] |
1178 |
| - /// |
1179 |
| - /// use std::collections::HashMap; |
1180 |
| - /// let mut squares = HashMap::new(); |
1181 |
| - /// for i in -10..=10 { |
1182 |
| - /// // This will not panic, since all keys are unique. |
1183 |
| - /// squares.insert(i, i * i).unwrap_none(); |
1184 |
| - /// } |
1185 |
| - /// ``` |
1186 |
| - /// |
1187 |
| - /// ```should_panic |
1188 |
| - /// #![feature(option_unwrap_none)] |
1189 |
| - /// |
1190 |
| - /// use std::collections::HashMap; |
1191 |
| - /// let mut sqrts = HashMap::new(); |
1192 |
| - /// for i in -10..=10 { |
1193 |
| - /// // This will panic, since both negative and positive `i` will |
1194 |
| - /// // insert the same `i * i` key, returning the old `Some(i)`. |
1195 |
| - /// sqrts.insert(i * i, i).unwrap_none(); |
1196 |
| - /// } |
1197 |
| - /// ``` |
1198 |
| - #[inline] |
1199 |
| - #[track_caller] |
1200 |
| - #[unstable(feature = "option_unwrap_none", reason = "newly added", issue = "62633")] |
1201 |
| - pub fn unwrap_none(self) { |
1202 |
| - if let Some(val) = self { |
1203 |
| - expect_none_failed("called `Option::unwrap_none()` on a `Some` value", &val); |
1204 |
| - } |
1205 |
| - } |
1206 |
| -} |
1207 |
| - |
1208 | 1124 | impl<T: Default> Option<T> {
|
1209 | 1125 | /// Returns the contained [`Some`] value or a default
|
1210 | 1126 | ///
|
@@ -1321,14 +1237,6 @@ fn expect_failed(msg: &str) -> ! {
|
1321 | 1237 | panic!("{}", msg)
|
1322 | 1238 | }
|
1323 | 1239 |
|
1324 |
| -// This is a separate function to reduce the code size of .expect_none() itself. |
1325 |
| -#[inline(never)] |
1326 |
| -#[cold] |
1327 |
| -#[track_caller] |
1328 |
| -fn expect_none_failed(msg: &str, value: &dyn fmt::Debug) -> ! { |
1329 |
| - panic!("{}: {:?}", msg, value) |
1330 |
| -} |
1331 |
| - |
1332 | 1240 | /////////////////////////////////////////////////////////////////////////////
|
1333 | 1241 | // Trait implementations
|
1334 | 1242 | /////////////////////////////////////////////////////////////////////////////
|
|
0 commit comments