Skip to content

Commit 86bccb6

Browse files
committed
Auto merge of #75541 - camelid:intra-doc-links-for-core-option, r=jyn514
Switch to intra-doc links in `core::option` Part of #75080. I didn't change some of the links since they link into `std` and you can't link from `core` to `std` (#74481). Also, at least one other link can't be switched to an intra-doc link because it's not supported yet (#74489).
2 parents f032cba + 8227b3b commit 86bccb6

File tree

1 file changed

+22
-90
lines changed

1 file changed

+22
-90
lines changed

library/core/src/option.rs

Lines changed: 22 additions & 90 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,6 @@ 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
703672
#[inline]
704673
#[stable(feature = "option_filter", since = "1.27.0")]
705674
pub fn filter<P: FnOnce(&T) -> bool>(self, predicate: P) -> Self {
@@ -717,7 +686,7 @@ impl<T> Option<T> {
717686
/// result of a function call, it is recommended to use [`or_else`], which is
718687
/// lazily evaluated.
719688
///
720-
/// [`or_else`]: #method.or_else
689+
/// [`or_else`]: Option::or_else
721690
///
722691
/// # Examples
723692
///
@@ -771,9 +740,6 @@ impl<T> Option<T> {
771740

772741
/// Returns [`Some`] if exactly one of `self`, `optb` is [`Some`], otherwise returns [`None`].
773742
///
774-
/// [`Some`]: #variant.Some
775-
/// [`None`]: #variant.None
776-
///
777743
/// # Examples
778744
///
779745
/// ```
@@ -810,8 +776,6 @@ impl<T> Option<T> {
810776
/// Inserts `v` into the option if it is [`None`], then
811777
/// returns a mutable reference to the contained value.
812778
///
813-
/// [`None`]: #variant.None
814-
///
815779
/// # Examples
816780
///
817781
/// ```
@@ -835,8 +799,6 @@ impl<T> Option<T> {
835799
/// Inserts a value computed from `f` into the option if it is [`None`], then
836800
/// returns a mutable reference to the contained value.
837801
///
838-
/// [`None`]: #variant.None
839-
///
840802
/// # Examples
841803
///
842804
/// ```
@@ -872,8 +834,6 @@ impl<T> Option<T> {
872834

873835
/// Takes the value out of the option, leaving a [`None`] in its place.
874836
///
875-
/// [`None`]: #variant.None
876-
///
877837
/// # Examples
878838
///
879839
/// ```
@@ -897,8 +857,6 @@ impl<T> Option<T> {
897857
/// returning the old value if present,
898858
/// leaving a [`Some`] in its place without deinitializing either one.
899859
///
900-
/// [`Some`]: #variant.Some
901-
///
902860
/// # Examples
903861
///
904862
/// ```
@@ -1062,9 +1020,6 @@ impl<T: fmt::Debug> Option<T> {
10621020
/// Panics if the value is a [`Some`], with a panic message including the
10631021
/// passed message, and the content of the [`Some`].
10641022
///
1065-
/// [`Some`]: #variant.Some
1066-
/// [`None`]: #variant.None
1067-
///
10681023
/// # Examples
10691024
///
10701025
/// ```
@@ -1105,8 +1060,7 @@ impl<T: fmt::Debug> Option<T> {
11051060
/// Panics if the value is a [`Some`], with a custom panic message provided
11061061
/// by the [`Some`]'s value.
11071062
///
1108-
/// [`Some(v)`]: #variant.Some
1109-
/// [`None`]: #variant.None
1063+
/// [`Some(v)`]: Some
11101064
///
11111065
/// # Examples
11121066
///
@@ -1166,11 +1120,9 @@ impl<T: Default> Option<T> {
11661120
/// assert_eq!(0, bad_year);
11671121
/// ```
11681122
///
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
11741126
#[inline]
11751127
#[stable(feature = "rust1", since = "1.0.0")]
11761128
pub fn unwrap_or_default(self) -> T {
@@ -1187,8 +1139,6 @@ impl<T: Deref> Option<T> {
11871139
/// Leaves the original Option in-place, creating a new one with a reference
11881140
/// to the original one, additionally coercing the contents via [`Deref`].
11891141
///
1190-
/// [`Deref`]: ../../std/ops/trait.Deref.html
1191-
///
11921142
/// # Examples
11931143
///
11941144
/// ```
@@ -1232,11 +1182,6 @@ impl<T, E> Option<Result<T, E>> {
12321182
/// [`Some`]`(`[`Ok`]`(_))` and [`Some`]`(`[`Err`]`(_))` will be mapped to
12331183
/// [`Ok`]`(`[`Some`]`(_))` and [`Err`]`(_)`.
12341184
///
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-
///
12401185
/// # Examples
12411186
///
12421187
/// ```
@@ -1384,9 +1329,8 @@ impl<'a, T> From<&'a Option<T>> for Option<&'a T> {
13841329
/// so this technique uses `as_ref` to first take an `Option` to a reference
13851330
/// to the value inside the original.
13861331
///
1387-
/// [`map`]: ../../std/option/enum.Option.html#method.map
1332+
/// [`map`]: Option::map
13881333
/// [`String`]: ../../std/string/struct.String.html
1389-
/// [`usize`]: ../../std/primitive.usize.html
13901334
///
13911335
/// ```
13921336
/// let s: Option<String> = Some(String::from("Hello, Rustaceans!"));
@@ -1465,10 +1409,6 @@ unsafe impl<A> TrustedLen for Item<A> {}
14651409
/// The iterator yields one value if the [`Option`] is a [`Some`], otherwise none.
14661410
///
14671411
/// 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
14721412
#[stable(feature = "rust1", since = "1.0.0")]
14731413
#[derive(Debug)]
14741414
pub struct Iter<'a, A: 'a> {
@@ -1519,10 +1459,6 @@ impl<A> Clone for Iter<'_, A> {
15191459
/// The iterator yields one value if the [`Option`] is a [`Some`], otherwise none.
15201460
///
15211461
/// 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
15261462
#[stable(feature = "rust1", since = "1.0.0")]
15271463
#[derive(Debug)]
15281464
pub struct IterMut<'a, A: 'a> {
@@ -1565,8 +1501,6 @@ unsafe impl<A> TrustedLen for IterMut<'_, A> {}
15651501
///
15661502
/// This `struct` is created by the [`Option::into_iter`] function.
15671503
///
1568-
/// [`Option`]: enum.Option.html
1569-
/// [`Some`]: enum.Option.html#variant.Some
15701504
/// [`Option::into_iter`]: enum.Option.html#method.into_iter
15711505
#[derive(Clone, Debug)]
15721506
#[stable(feature = "rust1", since = "1.0.0")]
@@ -1671,8 +1605,6 @@ impl<A, V: FromIterator<A>> FromIterator<Option<A>> for Option<V> {
16711605
///
16721606
/// Since the third element caused an underflow, no further elements were taken,
16731607
/// so the final value of `shared` is 6 (= `3 + 2 + 1`), not 16.
1674-
///
1675-
/// [`Iterator`]: ../iter/trait.Iterator.html
16761608
#[inline]
16771609
fn from_iter<I: IntoIterator<Item = Option<A>>>(iter: I) -> Option<V> {
16781610
// FIXME(#11084): This could be replaced with Iterator::scan when this

0 commit comments

Comments
 (0)