127
127
//! }
128
128
//! ```
129
129
//!
130
- //! [`Option`]: enum.Option.html
131
- //! [`Some`]: enum.Option.html#variant.Some
132
- //! [`None`]: enum.Option.html#variant.None
133
130
//! [`Box<T>`]: ../../std/boxed/struct.Box.html
134
- //! [`i32`]: ../../std/primitive.i32.html
135
131
136
132
#![ stable( feature = "rust1" , since = "1.0.0" ) ]
137
133
@@ -142,7 +138,7 @@ use crate::{
142
138
ops:: { self , Deref , DerefMut } ,
143
139
} ;
144
140
145
- /// The `Option` type. See [the module level documentation](index.html ) for more.
141
+ /// The `Option` type. See [the module level documentation](self ) for more.
146
142
#[ derive( Copy , PartialEq , PartialOrd , Eq , Ord , Debug , Hash ) ]
147
143
#[ rustc_diagnostic_item = "option_type" ]
148
144
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -175,8 +171,6 @@ impl<T> Option<T> {
175
171
/// let x: Option<u32> = None;
176
172
/// assert_eq!(x.is_some(), false);
177
173
/// ```
178
- ///
179
- /// [`Some`]: #variant.Some
180
174
#[ must_use = "if you intended to assert that this has a value, consider `.unwrap()` instead" ]
181
175
#[ inline]
182
176
#[ rustc_const_unstable( feature = "const_option" , issue = "67441" ) ]
@@ -196,8 +190,6 @@ impl<T> Option<T> {
196
190
/// let x: Option<u32> = None;
197
191
/// assert_eq!(x.is_none(), true);
198
192
/// ```
199
- ///
200
- /// [`None`]: #variant.None
201
193
#[ must_use = "if you intended to assert that this doesn't have a value, consider \
202
194
`.and_then(|| panic!(\" `Option` had a value when expected `None`\" ))` instead"]
203
195
#[ inline]
@@ -249,9 +241,8 @@ impl<T> Option<T> {
249
241
/// so this technique uses `as_ref` to first take an `Option` to a reference
250
242
/// to the value inside the original.
251
243
///
252
- /// [`map`]: enum. Option.html#method. map
244
+ /// [`map`]: Option:: map
253
245
/// [`String`]: ../../std/string/struct.String.html
254
- /// [`usize`]: ../../std/primitive.usize.html
255
246
///
256
247
/// ```
257
248
/// let text: Option<String> = Some("Hello, world!".to_string());
@@ -292,8 +283,6 @@ impl<T> Option<T> {
292
283
}
293
284
294
285
/// Converts from [`Pin`]`<&Option<T>>` to `Option<`[`Pin`]`<&T>>`.
295
- ///
296
- /// [`Pin`]: ../pin/struct.Pin.html
297
286
#[ inline]
298
287
#[ stable( feature = "pin" , since = "1.33.0" ) ]
299
288
pub fn as_pin_ref ( self : Pin < & Self > ) -> Option < Pin < & T > > {
@@ -303,8 +292,6 @@ impl<T> Option<T> {
303
292
}
304
293
305
294
/// Converts from [`Pin`]`<&mut Option<T>>` to `Option<`[`Pin`]`<&mut T>>`.
306
- ///
307
- /// [`Pin`]: ../pin/struct.Pin.html
308
295
#[ inline]
309
296
#[ stable( feature = "pin" , since = "1.33.0" ) ]
310
297
pub fn as_pin_mut ( self : Pin < & mut Self > ) -> Option < Pin < & mut T > > {
@@ -324,9 +311,6 @@ impl<T> Option<T> {
324
311
/// Panics if the value is a [`None`] with a custom panic message provided by
325
312
/// `msg`.
326
313
///
327
- /// [`Some`]: #variant.Some
328
- /// [`None`]: #variant.None
329
- ///
330
314
/// # Examples
331
315
///
332
316
/// ```
@@ -355,17 +339,14 @@ impl<T> Option<T> {
355
339
/// case explicitly, or call [`unwrap_or`], [`unwrap_or_else`], or
356
340
/// [`unwrap_or_default`].
357
341
///
358
- /// [`unwrap_or`]: #method. unwrap_or
359
- /// [`unwrap_or_else`]: #method. unwrap_or_else
360
- /// [`unwrap_or_default`]: #method. unwrap_or_default
342
+ /// [`unwrap_or`]: Option:: unwrap_or
343
+ /// [`unwrap_or_else`]: Option:: unwrap_or_else
344
+ /// [`unwrap_or_default`]: Option:: unwrap_or_default
361
345
///
362
346
/// # Panics
363
347
///
364
348
/// Panics if the self value equals [`None`].
365
349
///
366
- /// [`Some`]: #variant.Some
367
- /// [`None`]: #variant.None
368
- ///
369
350
/// # Examples
370
351
///
371
352
/// ```
@@ -394,8 +375,7 @@ impl<T> Option<T> {
394
375
/// the result of a function call, it is recommended to use [`unwrap_or_else`],
395
376
/// which is lazily evaluated.
396
377
///
397
- /// [`Some`]: #variant.Some
398
- /// [`unwrap_or_else`]: #method.unwrap_or_else
378
+ /// [`unwrap_or_else`]: Option::unwrap_or_else
399
379
///
400
380
/// # Examples
401
381
///
@@ -441,8 +421,6 @@ impl<T> Option<T> {
441
421
/// Converts an `Option<`[`String`]`>` into an `Option<`[`usize`]`>`, consuming the original:
442
422
///
443
423
/// [`String`]: ../../std/string/struct.String.html
444
- /// [`usize`]: ../../std/primitive.usize.html
445
- ///
446
424
/// ```
447
425
/// let maybe_some_string = Some(String::from("Hello, World!"));
448
426
/// // `Option::map` takes self *by value*, consuming `maybe_some_string`
@@ -466,7 +444,7 @@ impl<T> Option<T> {
466
444
/// the result of a function call, it is recommended to use [`map_or_else`],
467
445
/// which is lazily evaluated.
468
446
///
469
- /// [`map_or_else`]: #method. map_or_else
447
+ /// [`map_or_else`]: Option:: map_or_else
470
448
///
471
449
/// # Examples
472
450
///
@@ -516,12 +494,11 @@ impl<T> Option<T> {
516
494
/// result of a function call, it is recommended to use [`ok_or_else`], which is
517
495
/// lazily evaluated.
518
496
///
519
- /// [`Result<T, E>`]: ../../std/result/enum.Result.html
520
- /// [`Ok(v)`]: ../../std/result/enum.Result.html#variant.Ok
521
- /// [`Err(err)`]: ../../std/result/enum.Result.html#variant.Err
522
- /// [`None`]: #variant.None
523
- /// [`Some(v)`]: #variant.Some
524
- /// [`ok_or_else`]: #method.ok_or_else
497
+ /// [`Result<T, E>`]: Result
498
+ /// [`Ok(v)`]: Ok
499
+ /// [`Err(err)`]: Err
500
+ /// [`Some(v)`]: Some
501
+ /// [`ok_or_else`]: Option::ok_or_else
525
502
///
526
503
/// # Examples
527
504
///
@@ -544,11 +521,10 @@ impl<T> Option<T> {
544
521
/// Transforms the `Option<T>` into a [`Result<T, E>`], mapping [`Some(v)`] to
545
522
/// [`Ok(v)`] and [`None`] to [`Err(err())`].
546
523
///
547
- /// [`Result<T, E>`]: ../../std/result/enum.Result.html
548
- /// [`Ok(v)`]: ../../std/result/enum.Result.html#variant.Ok
549
- /// [`Err(err())`]: ../../std/result/enum.Result.html#variant.Err
550
- /// [`None`]: #variant.None
551
- /// [`Some(v)`]: #variant.Some
524
+ /// [`Result<T, E>`]: Result
525
+ /// [`Ok(v)`]: Ok
526
+ /// [`Err(err())`]: Err
527
+ /// [`Some(v)`]: Some
552
528
///
553
529
/// # Examples
554
530
///
@@ -617,8 +593,6 @@ impl<T> Option<T> {
617
593
618
594
/// Returns [`None`] if the option is [`None`], otherwise returns `optb`.
619
595
///
620
- /// [`None`]: #variant.None
621
- ///
622
596
/// # Examples
623
597
///
624
598
/// ```
@@ -652,8 +626,6 @@ impl<T> Option<T> {
652
626
///
653
627
/// Some languages call this operation flatmap.
654
628
///
655
- /// [`None`]: #variant.None
656
- ///
657
629
/// # Examples
658
630
///
659
631
/// ```
@@ -697,9 +669,6 @@ impl<T> Option<T> {
697
669
/// assert_eq!(Some(4).filter(is_even), Some(4));
698
670
/// ```
699
671
///
700
- /// [`None`]: #variant.None
701
- /// [`Some(t)`]: #variant.Some
702
- /// [`Iterator::filter()`]: ../../std/iter/trait.Iterator.html#method.filter
703
672
#[ inline]
704
673
#[ stable( feature = "option_filter" , since = "1.27.0" ) ]
705
674
pub fn filter < P : FnOnce ( & T ) -> bool > ( self , predicate : P ) -> Self {
@@ -717,7 +686,7 @@ impl<T> Option<T> {
717
686
/// result of a function call, it is recommended to use [`or_else`], which is
718
687
/// lazily evaluated.
719
688
///
720
- /// [`or_else`]: #method. or_else
689
+ /// [`or_else`]: Option:: or_else
721
690
///
722
691
/// # Examples
723
692
///
@@ -771,9 +740,6 @@ impl<T> Option<T> {
771
740
772
741
/// Returns [`Some`] if exactly one of `self`, `optb` is [`Some`], otherwise returns [`None`].
773
742
///
774
- /// [`Some`]: #variant.Some
775
- /// [`None`]: #variant.None
776
- ///
777
743
/// # Examples
778
744
///
779
745
/// ```
@@ -810,8 +776,6 @@ impl<T> Option<T> {
810
776
/// Inserts `v` into the option if it is [`None`], then
811
777
/// returns a mutable reference to the contained value.
812
778
///
813
- /// [`None`]: #variant.None
814
- ///
815
779
/// # Examples
816
780
///
817
781
/// ```
@@ -835,8 +799,6 @@ impl<T> Option<T> {
835
799
/// Inserts a value computed from `f` into the option if it is [`None`], then
836
800
/// returns a mutable reference to the contained value.
837
801
///
838
- /// [`None`]: #variant.None
839
- ///
840
802
/// # Examples
841
803
///
842
804
/// ```
@@ -872,8 +834,6 @@ impl<T> Option<T> {
872
834
873
835
/// Takes the value out of the option, leaving a [`None`] in its place.
874
836
///
875
- /// [`None`]: #variant.None
876
- ///
877
837
/// # Examples
878
838
///
879
839
/// ```
@@ -897,8 +857,6 @@ impl<T> Option<T> {
897
857
/// returning the old value if present,
898
858
/// leaving a [`Some`] in its place without deinitializing either one.
899
859
///
900
- /// [`Some`]: #variant.Some
901
- ///
902
860
/// # Examples
903
861
///
904
862
/// ```
@@ -1062,9 +1020,6 @@ impl<T: fmt::Debug> Option<T> {
1062
1020
/// Panics if the value is a [`Some`], with a panic message including the
1063
1021
/// passed message, and the content of the [`Some`].
1064
1022
///
1065
- /// [`Some`]: #variant.Some
1066
- /// [`None`]: #variant.None
1067
- ///
1068
1023
/// # Examples
1069
1024
///
1070
1025
/// ```
@@ -1105,8 +1060,7 @@ impl<T: fmt::Debug> Option<T> {
1105
1060
/// Panics if the value is a [`Some`], with a custom panic message provided
1106
1061
/// by the [`Some`]'s value.
1107
1062
///
1108
- /// [`Some(v)`]: #variant.Some
1109
- /// [`None`]: #variant.None
1063
+ /// [`Some(v)`]: Some
1110
1064
///
1111
1065
/// # Examples
1112
1066
///
@@ -1166,11 +1120,9 @@ impl<T: Default> Option<T> {
1166
1120
/// assert_eq!(0, bad_year);
1167
1121
/// ```
1168
1122
///
1169
- /// [`Some`]: #variant.Some
1170
- /// [`None`]: #variant.None
1171
- /// [default value]: ../default/trait.Default.html#tymethod.default
1172
- /// [`parse`]: ../../std/primitive.str.html#method.parse
1173
- /// [`FromStr`]: ../../std/str/trait.FromStr.html
1123
+ /// [default value]: Default::default
1124
+ /// [`parse`]: str::parse
1125
+ /// [`FromStr`]: crate::str::FromStr
1174
1126
#[ inline]
1175
1127
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1176
1128
pub fn unwrap_or_default ( self ) -> T {
@@ -1187,8 +1139,6 @@ impl<T: Deref> Option<T> {
1187
1139
/// Leaves the original Option in-place, creating a new one with a reference
1188
1140
/// to the original one, additionally coercing the contents via [`Deref`].
1189
1141
///
1190
- /// [`Deref`]: ../../std/ops/trait.Deref.html
1191
- ///
1192
1142
/// # Examples
1193
1143
///
1194
1144
/// ```
@@ -1232,11 +1182,6 @@ impl<T, E> Option<Result<T, E>> {
1232
1182
/// [`Some`]`(`[`Ok`]`(_))` and [`Some`]`(`[`Err`]`(_))` will be mapped to
1233
1183
/// [`Ok`]`(`[`Some`]`(_))` and [`Err`]`(_)`.
1234
1184
///
1235
- /// [`None`]: #variant.None
1236
- /// [`Ok`]: ../../std/result/enum.Result.html#variant.Ok
1237
- /// [`Some`]: #variant.Some
1238
- /// [`Err`]: ../../std/result/enum.Result.html#variant.Err
1239
- ///
1240
1185
/// # Examples
1241
1186
///
1242
1187
/// ```
@@ -1384,9 +1329,8 @@ impl<'a, T> From<&'a Option<T>> for Option<&'a T> {
1384
1329
/// so this technique uses `as_ref` to first take an `Option` to a reference
1385
1330
/// to the value inside the original.
1386
1331
///
1387
- /// [`map`]: ../../std/option/enum. Option.html#method. map
1332
+ /// [`map`]: Option:: map
1388
1333
/// [`String`]: ../../std/string/struct.String.html
1389
- /// [`usize`]: ../../std/primitive.usize.html
1390
1334
///
1391
1335
/// ```
1392
1336
/// let s: Option<String> = Some(String::from("Hello, Rustaceans!"));
@@ -1465,10 +1409,6 @@ unsafe impl<A> TrustedLen for Item<A> {}
1465
1409
/// The iterator yields one value if the [`Option`] is a [`Some`], otherwise none.
1466
1410
///
1467
1411
/// This `struct` is created by the [`Option::iter`] function.
1468
- ///
1469
- /// [`Option`]: enum.Option.html
1470
- /// [`Some`]: enum.Option.html#variant.Some
1471
- /// [`Option::iter`]: enum.Option.html#method.iter
1472
1412
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1473
1413
#[ derive( Debug ) ]
1474
1414
pub struct Iter < ' a , A : ' a > {
@@ -1519,10 +1459,6 @@ impl<A> Clone for Iter<'_, A> {
1519
1459
/// The iterator yields one value if the [`Option`] is a [`Some`], otherwise none.
1520
1460
///
1521
1461
/// This `struct` is created by the [`Option::iter_mut`] function.
1522
- ///
1523
- /// [`Option`]: enum.Option.html
1524
- /// [`Some`]: enum.Option.html#variant.Some
1525
- /// [`Option::iter_mut`]: enum.Option.html#method.iter_mut
1526
1462
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1527
1463
#[ derive( Debug ) ]
1528
1464
pub struct IterMut < ' a , A : ' a > {
@@ -1565,8 +1501,6 @@ unsafe impl<A> TrustedLen for IterMut<'_, A> {}
1565
1501
///
1566
1502
/// This `struct` is created by the [`Option::into_iter`] function.
1567
1503
///
1568
- /// [`Option`]: enum.Option.html
1569
- /// [`Some`]: enum.Option.html#variant.Some
1570
1504
/// [`Option::into_iter`]: enum.Option.html#method.into_iter
1571
1505
#[ derive( Clone , Debug ) ]
1572
1506
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -1671,8 +1605,6 @@ impl<A, V: FromIterator<A>> FromIterator<Option<A>> for Option<V> {
1671
1605
///
1672
1606
/// Since the third element caused an underflow, no further elements were taken,
1673
1607
/// so the final value of `shared` is 6 (= `3 + 2 + 1`), not 16.
1674
- ///
1675
- /// [`Iterator`]: ../iter/trait.Iterator.html
1676
1608
#[ inline]
1677
1609
fn from_iter < I : IntoIterator < Item = Option < A > > > ( iter : I ) -> Option < V > {
1678
1610
// FIXME(#11084): This could be replaced with Iterator::scan when this
0 commit comments