Skip to content

Commit b1c05c5

Browse files
committed
Switch to intra-doc links in core::option
1 parent 8e21bd0 commit b1c05c5

File tree

1 file changed

+23
-92
lines changed

1 file changed

+23
-92
lines changed

library/core/src/option.rs

Lines changed: 23 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,7 @@
127127
//! }
128128
//! ```
129129
//!
130-
//! [`Option`]: enum.Option.html
131-
//! [`Some`]: enum.Option.html#variant.Some
132-
//! [`None`]: enum.Option.html#variant.None
133130
//! [`Box<T>`]: ../../std/boxed/struct.Box.html
134-
//! [`i32`]: ../../std/primitive.i32.html
135131
136132
#![stable(feature = "rust1", since = "1.0.0")]
137133

@@ -142,7 +138,7 @@ use crate::{
142138
ops::{self, Deref, DerefMut},
143139
};
144140

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.
146142
#[derive(Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]
147143
#[rustc_diagnostic_item = "option_type"]
148144
#[stable(feature = "rust1", since = "1.0.0")]
@@ -175,8 +171,6 @@ impl<T> Option<T> {
175171
/// let x: Option<u32> = None;
176172
/// assert_eq!(x.is_some(), false);
177173
/// ```
178-
///
179-
/// [`Some`]: #variant.Some
180174
#[must_use = "if you intended to assert that this has a value, consider `.unwrap()` instead"]
181175
#[inline]
182176
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
@@ -196,8 +190,6 @@ impl<T> Option<T> {
196190
/// let x: Option<u32> = None;
197191
/// assert_eq!(x.is_none(), true);
198192
/// ```
199-
///
200-
/// [`None`]: #variant.None
201193
#[must_use = "if you intended to assert that this doesn't have a value, consider \
202194
`.and_then(|| panic!(\"`Option` had a value when expected `None`\"))` instead"]
203195
#[inline]
@@ -249,9 +241,8 @@ impl<T> Option<T> {
249241
/// so this technique uses `as_ref` to first take an `Option` to a reference
250242
/// to the value inside the original.
251243
///
252-
/// [`map`]: enum.Option.html#method.map
244+
/// [`map`]: Option::map
253245
/// [`String`]: ../../std/string/struct.String.html
254-
/// [`usize`]: ../../std/primitive.usize.html
255246
///
256247
/// ```
257248
/// let text: Option<String> = Some("Hello, world!".to_string());
@@ -292,8 +283,6 @@ impl<T> Option<T> {
292283
}
293284

294285
/// Converts from [`Pin`]`<&Option<T>>` to `Option<`[`Pin`]`<&T>>`.
295-
///
296-
/// [`Pin`]: ../pin/struct.Pin.html
297286
#[inline]
298287
#[stable(feature = "pin", since = "1.33.0")]
299288
pub fn as_pin_ref(self: Pin<&Self>) -> Option<Pin<&T>> {
@@ -303,8 +292,6 @@ impl<T> Option<T> {
303292
}
304293

305294
/// Converts from [`Pin`]`<&mut Option<T>>` to `Option<`[`Pin`]`<&mut T>>`.
306-
///
307-
/// [`Pin`]: ../pin/struct.Pin.html
308295
#[inline]
309296
#[stable(feature = "pin", since = "1.33.0")]
310297
pub fn as_pin_mut(self: Pin<&mut Self>) -> Option<Pin<&mut T>> {
@@ -324,9 +311,6 @@ impl<T> Option<T> {
324311
/// Panics if the value is a [`None`] with a custom panic message provided by
325312
/// `msg`.
326313
///
327-
/// [`Some`]: #variant.Some
328-
/// [`None`]: #variant.None
329-
///
330314
/// # Examples
331315
///
332316
/// ```
@@ -355,17 +339,14 @@ impl<T> Option<T> {
355339
/// case explicitly, or call [`unwrap_or`], [`unwrap_or_else`], or
356340
/// [`unwrap_or_default`].
357341
///
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
361345
///
362346
/// # Panics
363347
///
364348
/// Panics if the self value equals [`None`].
365349
///
366-
/// [`Some`]: #variant.Some
367-
/// [`None`]: #variant.None
368-
///
369350
/// # Examples
370351
///
371352
/// ```
@@ -394,8 +375,7 @@ impl<T> Option<T> {
394375
/// the result of a function call, it is recommended to use [`unwrap_or_else`],
395376
/// which is lazily evaluated.
396377
///
397-
/// [`Some`]: #variant.Some
398-
/// [`unwrap_or_else`]: #method.unwrap_or_else
378+
/// [`unwrap_or_else`]: Option::unwrap_or_else
399379
///
400380
/// # Examples
401381
///
@@ -441,8 +421,6 @@ impl<T> Option<T> {
441421
/// Converts an `Option<`[`String`]`>` into an `Option<`[`usize`]`>`, consuming the original:
442422
///
443423
/// [`String`]: ../../std/string/struct.String.html
444-
/// [`usize`]: ../../std/primitive.usize.html
445-
///
446424
/// ```
447425
/// let maybe_some_string = Some(String::from("Hello, World!"));
448426
/// // `Option::map` takes self *by value*, consuming `maybe_some_string`
@@ -466,7 +444,7 @@ impl<T> Option<T> {
466444
/// the result of a function call, it is recommended to use [`map_or_else`],
467445
/// which is lazily evaluated.
468446
///
469-
/// [`map_or_else`]: #method.map_or_else
447+
/// [`map_or_else`]: Option::map_or_else
470448
///
471449
/// # Examples
472450
///
@@ -516,12 +494,11 @@ impl<T> Option<T> {
516494
/// result of a function call, it is recommended to use [`ok_or_else`], which is
517495
/// lazily evaluated.
518496
///
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
525502
///
526503
/// # Examples
527504
///
@@ -544,11 +521,10 @@ impl<T> Option<T> {
544521
/// Transforms the `Option<T>` into a [`Result<T, E>`], mapping [`Some(v)`] to
545522
/// [`Ok(v)`] and [`None`] to [`Err(err())`].
546523
///
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
552528
///
553529
/// # Examples
554530
///
@@ -617,8 +593,6 @@ impl<T> Option<T> {
617593

618594
/// Returns [`None`] if the option is [`None`], otherwise returns `optb`.
619595
///
620-
/// [`None`]: #variant.None
621-
///
622596
/// # Examples
623597
///
624598
/// ```
@@ -652,8 +626,6 @@ impl<T> Option<T> {
652626
///
653627
/// Some languages call this operation flatmap.
654628
///
655-
/// [`None`]: #variant.None
656-
///
657629
/// # Examples
658630
///
659631
/// ```
@@ -697,9 +669,7 @@ impl<T> Option<T> {
697669
/// assert_eq!(Some(4).filter(is_even), Some(4));
698670
/// ```
699671
///
700-
/// [`None`]: #variant.None
701-
/// [`Some(t)`]: #variant.Some
702-
/// [`Iterator::filter()`]: ../../std/iter/trait.Iterator.html#method.filter
672+
/// [`Iterator::filter()`]: Iterator::filter
703673
#[inline]
704674
#[stable(feature = "option_filter", since = "1.27.0")]
705675
pub fn filter<P: FnOnce(&T) -> bool>(self, predicate: P) -> Self {
@@ -717,7 +687,7 @@ impl<T> Option<T> {
717687
/// result of a function call, it is recommended to use [`or_else`], which is
718688
/// lazily evaluated.
719689
///
720-
/// [`or_else`]: #method.or_else
690+
/// [`or_else`]: Option::or_else
721691
///
722692
/// # Examples
723693
///
@@ -771,9 +741,6 @@ impl<T> Option<T> {
771741

772742
/// Returns [`Some`] if exactly one of `self`, `optb` is [`Some`], otherwise returns [`None`].
773743
///
774-
/// [`Some`]: #variant.Some
775-
/// [`None`]: #variant.None
776-
///
777744
/// # Examples
778745
///
779746
/// ```
@@ -810,8 +777,6 @@ impl<T> Option<T> {
810777
/// Inserts `v` into the option if it is [`None`], then
811778
/// returns a mutable reference to the contained value.
812779
///
813-
/// [`None`]: #variant.None
814-
///
815780
/// # Examples
816781
///
817782
/// ```
@@ -835,8 +800,6 @@ impl<T> Option<T> {
835800
/// Inserts a value computed from `f` into the option if it is [`None`], then
836801
/// returns a mutable reference to the contained value.
837802
///
838-
/// [`None`]: #variant.None
839-
///
840803
/// # Examples
841804
///
842805
/// ```
@@ -872,8 +835,6 @@ impl<T> Option<T> {
872835

873836
/// Takes the value out of the option, leaving a [`None`] in its place.
874837
///
875-
/// [`None`]: #variant.None
876-
///
877838
/// # Examples
878839
///
879840
/// ```
@@ -897,8 +858,6 @@ impl<T> Option<T> {
897858
/// returning the old value if present,
898859
/// leaving a [`Some`] in its place without deinitializing either one.
899860
///
900-
/// [`Some`]: #variant.Some
901-
///
902861
/// # Examples
903862
///
904863
/// ```
@@ -1062,9 +1021,6 @@ impl<T: fmt::Debug> Option<T> {
10621021
/// Panics if the value is a [`Some`], with a panic message including the
10631022
/// passed message, and the content of the [`Some`].
10641023
///
1065-
/// [`Some`]: #variant.Some
1066-
/// [`None`]: #variant.None
1067-
///
10681024
/// # Examples
10691025
///
10701026
/// ```
@@ -1105,8 +1061,7 @@ impl<T: fmt::Debug> Option<T> {
11051061
/// Panics if the value is a [`Some`], with a custom panic message provided
11061062
/// by the [`Some`]'s value.
11071063
///
1108-
/// [`Some(v)`]: #variant.Some
1109-
/// [`None`]: #variant.None
1064+
/// [`Some(v)`]: Some
11101065
///
11111066
/// # Examples
11121067
///
@@ -1166,11 +1121,9 @@ impl<T: Default> Option<T> {
11661121
/// assert_eq!(0, bad_year);
11671122
/// ```
11681123
///
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
1124+
/// [default value]: Default::default
1125+
/// [`parse`]: str::parse
1126+
/// [`FromStr`]: crate::str::FromStr
11741127
#[inline]
11751128
#[stable(feature = "rust1", since = "1.0.0")]
11761129
pub fn unwrap_or_default(self) -> T {
@@ -1187,8 +1140,6 @@ impl<T: Deref> Option<T> {
11871140
/// Leaves the original Option in-place, creating a new one with a reference
11881141
/// to the original one, additionally coercing the contents via [`Deref`].
11891142
///
1190-
/// [`Deref`]: ../../std/ops/trait.Deref.html
1191-
///
11921143
/// # Examples
11931144
///
11941145
/// ```
@@ -1232,11 +1183,6 @@ impl<T, E> Option<Result<T, E>> {
12321183
/// [`Some`]`(`[`Ok`]`(_))` and [`Some`]`(`[`Err`]`(_))` will be mapped to
12331184
/// [`Ok`]`(`[`Some`]`(_))` and [`Err`]`(_)`.
12341185
///
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-
///
12401186
/// # Examples
12411187
///
12421188
/// ```
@@ -1384,9 +1330,8 @@ impl<'a, T> From<&'a Option<T>> for Option<&'a T> {
13841330
/// so this technique uses `as_ref` to first take an `Option` to a reference
13851331
/// to the value inside the original.
13861332
///
1387-
/// [`map`]: ../../std/option/enum.Option.html#method.map
1333+
/// [`map`]: Option::map
13881334
/// [`String`]: ../../std/string/struct.String.html
1389-
/// [`usize`]: ../../std/primitive.usize.html
13901335
///
13911336
/// ```
13921337
/// let s: Option<String> = Some(String::from("Hello, Rustaceans!"));
@@ -1465,10 +1410,6 @@ unsafe impl<A> TrustedLen for Item<A> {}
14651410
/// The iterator yields one value if the [`Option`] is a [`Some`], otherwise none.
14661411
///
14671412
/// 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
14721413
#[stable(feature = "rust1", since = "1.0.0")]
14731414
#[derive(Debug)]
14741415
pub struct Iter<'a, A: 'a> {
@@ -1519,10 +1460,6 @@ impl<A> Clone for Iter<'_, A> {
15191460
/// The iterator yields one value if the [`Option`] is a [`Some`], otherwise none.
15201461
///
15211462
/// 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
15261463
#[stable(feature = "rust1", since = "1.0.0")]
15271464
#[derive(Debug)]
15281465
pub struct IterMut<'a, A: 'a> {
@@ -1564,10 +1501,6 @@ unsafe impl<A> TrustedLen for IterMut<'_, A> {}
15641501
/// The iterator yields one value if the [`Option`] is a [`Some`], otherwise none.
15651502
///
15661503
/// This `struct` is created by the [`Option::into_iter`] function.
1567-
///
1568-
/// [`Option`]: enum.Option.html
1569-
/// [`Some`]: enum.Option.html#variant.Some
1570-
/// [`Option::into_iter`]: enum.Option.html#method.into_iter
15711504
#[derive(Clone, Debug)]
15721505
#[stable(feature = "rust1", since = "1.0.0")]
15731506
pub struct IntoIter<A> {
@@ -1671,8 +1604,6 @@ impl<A, V: FromIterator<A>> FromIterator<Option<A>> for Option<V> {
16711604
///
16721605
/// Since the third element caused an underflow, no further elements were taken,
16731606
/// so the final value of `shared` is 6 (= `3 + 2 + 1`), not 16.
1674-
///
1675-
/// [`Iterator`]: ../iter/trait.Iterator.html
16761607
#[inline]
16771608
fn from_iter<I: IntoIterator<Item = Option<A>>>(iter: I) -> Option<V> {
16781609
// FIXME(#11084): This could be replaced with Iterator::scan when this

0 commit comments

Comments
 (0)