Skip to content

Commit d41d3a5

Browse files
committed
Improve formatting of the primitive str documentation
Adds extra documentation links for library types and methods to be consistent with similar items already linked. Also includes minor formatting fixes.
1 parent 0913004 commit d41d3a5

File tree

1 file changed

+35
-17
lines changed

1 file changed

+35
-17
lines changed

src/libcollections/str.rs

+35-17
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,11 @@ impl str {
267267
/// Converts a string slice to a raw pointer.
268268
///
269269
/// As string slices are a slice of bytes, the raw pointer points to a
270-
/// `u8`. This pointer will be pointing to the first byte of the string
270+
/// [`u8`]. This pointer will be pointing to the first byte of the string
271271
/// slice.
272272
///
273+
/// [`u8`]: primitive.u8.html
274+
///
273275
/// # Examples
274276
///
275277
/// Basic usage:
@@ -661,7 +663,7 @@ impl str {
661663
/// assert_eq!(None, chars.next());
662664
/// ```
663665
///
664-
/// Remember, `char`s may not match your human intuition about characters:
666+
/// Remember, [`char`]s may not match your human intuition about characters:
665667
///
666668
/// ```
667669
/// let y = "y̆";
@@ -678,16 +680,18 @@ impl str {
678680
pub fn chars(&self) -> Chars {
679681
core_str::StrExt::chars(self)
680682
}
681-
/// Returns an iterator over the `char`s of a string slice, and their
683+
/// Returns an iterator over the [`char`]s of a string slice, and their
682684
/// positions.
683685
///
684686
/// As a string slice consists of valid UTF-8, we can iterate through a
685-
/// string slice by `char`. This method returns an iterator of both
686-
/// these `char`s, as well as their byte positions.
687+
/// string slice by [`char`]. This method returns an iterator of both
688+
/// these [`char`]s, as well as their byte positions.
687689
///
688-
/// The iterator yields tuples. The position is first, the `char` is
690+
/// The iterator yields tuples. The position is first, the [`char`] is
689691
/// second.
690692
///
693+
/// [`char`]: primitive.char.html
694+
///
691695
/// # Examples
692696
///
693697
/// Basic usage:
@@ -711,7 +715,7 @@ impl str {
711715
/// assert_eq!(None, char_indices.next());
712716
/// ```
713717
///
714-
/// Remember, `char`s may not match your human intuition about characters:
718+
/// Remember, [`char`]s may not match your human intuition about characters:
715719
///
716720
/// ```
717721
/// let y = "y̆";
@@ -918,12 +922,13 @@ impl str {
918922
/// Returns the byte index of the first character of this string slice that
919923
/// matches the pattern.
920924
///
921-
/// Returns `None` if the pattern doesn't match.
925+
/// Returns [`None`] if the pattern doesn't match.
922926
///
923927
/// The pattern can be a `&str`, [`char`], or a closure that determines if
924928
/// a character matches.
925929
///
926930
/// [`char`]: primitive.char.html
931+
/// [`None`]: option/enum.Option.html#variant.None
927932
///
928933
/// # Examples
929934
///
@@ -962,12 +967,13 @@ impl str {
962967
/// Returns the byte index of the last character of this string slice that
963968
/// matches the pattern.
964969
///
965-
/// Returns `None` if the pattern doesn't match.
970+
/// Returns [`None`] if the pattern doesn't match.
966971
///
967972
/// The pattern can be a `&str`, [`char`], or a closure that determines if
968973
/// a character matches.
969974
///
970975
/// [`char`]: primitive.char.html
976+
/// [`None`]: option/enum.Option.html#variant.None
971977
///
972978
/// # Examples
973979
///
@@ -1187,14 +1193,18 @@ impl str {
11871193
/// An iterator over substrings of `self`, separated by characters
11881194
/// matched by a pattern and yielded in reverse order.
11891195
///
1190-
/// The pattern can be a simple `&str`, `char`, or a closure that
1196+
/// The pattern can be a simple `&str`, [`char`], or a closure that
11911197
/// determines the split.
11921198
/// Additional libraries might provide more complex patterns like
11931199
/// regular expressions.
11941200
///
1195-
/// Equivalent to `split`, except that the trailing substring is
1201+
/// [`char`]: primitive.char.html
1202+
///
1203+
/// Equivalent to [`split()`], except that the trailing substring is
11961204
/// skipped if empty.
11971205
///
1206+
/// [`split()`]: #method.split
1207+
///
11981208
/// This method can be used for string data that is _terminated_,
11991209
/// rather than _separated_ by a pattern.
12001210
///
@@ -1457,7 +1467,7 @@ impl str {
14571467
/// # Iterator behavior
14581468
///
14591469
/// The returned iterator requires that the pattern supports a reverse
1460-
/// search, and it will be a `[DoubleEndedIterator]` if a forward/reverse
1470+
/// search, and it will be a [`DoubleEndedIterator`] if a forward/reverse
14611471
/// search yields the same elements.
14621472
///
14631473
/// [`DoubleEndedIterator`]: iter/trait.DoubleEndedIterator.html
@@ -1694,9 +1704,11 @@ impl str {
16941704
///
16951705
/// # Errors
16961706
///
1697-
/// Will return `Err` if it's not possible to parse this string slice into
1707+
/// Will return [`Err`] if it's not possible to parse this string slice into
16981708
/// the desired type.
16991709
///
1710+
/// [`Err`]: str/trait.FromStr.html#associatedtype.Err
1711+
///
17001712
/// # Example
17011713
///
17021714
/// Basic usage
@@ -1707,7 +1719,7 @@ impl str {
17071719
/// assert_eq!(4, four);
17081720
/// ```
17091721
///
1710-
/// Using the 'turbofish' instead of annotationg `four`:
1722+
/// Using the 'turbofish' instead of annotating `four`:
17111723
///
17121724
/// ```
17131725
/// let four = "4".parse::<u32>();
@@ -1765,11 +1777,13 @@ impl str {
17651777
result
17661778
}
17671779

1768-
/// Returns the lowercase equivalent of this string slice, as a new `String`.
1780+
/// Returns the lowercase equivalent of this string slice, as a new [`String`].
17691781
///
17701782
/// 'Lowercase' is defined according to the terms of the Unicode Derived Core Property
17711783
/// `Lowercase`.
17721784
///
1785+
/// [`String`]: string/struct.String.html
1786+
///
17731787
/// # Examples
17741788
///
17751789
/// Basic usage:
@@ -1839,11 +1853,13 @@ impl str {
18391853
}
18401854
}
18411855

1842-
/// Returns the uppercase equivalent of this string slice, as a new `String`.
1856+
/// Returns the uppercase equivalent of this string slice, as a new [`String`].
18431857
///
18441858
/// 'Uppercase' is defined according to the terms of the Unicode Derived Core Property
18451859
/// `Uppercase`.
18461860
///
1861+
/// [`String`]: string/struct.String.html
1862+
///
18471863
/// # Examples
18481864
///
18491865
/// Basic usage:
@@ -1884,7 +1900,9 @@ impl str {
18841900
self.chars().flat_map(|c| c.escape_unicode()).collect()
18851901
}
18861902

1887-
/// Converts a `Box<str>` into a `String` without copying or allocating.
1903+
/// Converts a `Box<str>` into a [`String`] without copying or allocating.
1904+
///
1905+
/// [`String`]: string/struct.String.html
18881906
///
18891907
/// # Examples
18901908
///

0 commit comments

Comments
 (0)