Skip to content

Commit d4d35cf

Browse files
authored
Rollup merge of rust-lang#41243 - projektir:prim_str_docs, r=GuillaumeGomez
Minor nits in primitive str Some minor updates to linking, added some links, doc format, etc. r? @GuillaumeGomez
2 parents 1dd9801 + ed7b6c3 commit d4d35cf

File tree

2 files changed

+28
-17
lines changed

2 files changed

+28
-17
lines changed

src/libcollections/str.rs

+24-13
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,10 @@ impl str {
325325

326326
/// Returns a subslice of `str`.
327327
///
328-
/// This is the non-panicking alternative to indexing the `str`. Returns `None` whenever
329-
/// equivalent indexing operation would panic.
328+
/// This is the non-panicking alternative to indexing the `str`. Returns
329+
/// [`None`] whenever equivalent indexing operation would panic.
330+
///
331+
/// [`None`]: option/enum.Option.html#variant.None
330332
///
331333
/// # Examples
332334
///
@@ -346,8 +348,10 @@ impl str {
346348

347349
/// Returns a mutable subslice of `str`.
348350
///
349-
/// This is the non-panicking alternative to indexing the `str`. Returns `None` whenever
350-
/// equivalent indexing operation would panic.
351+
/// This is the non-panicking alternative to indexing the `str`. Returns
352+
/// [`None`] whenever equivalent indexing operation would panic.
353+
///
354+
/// [`None`]: option/enum.Option.html#variant.None
351355
///
352356
/// # Examples
353357
///
@@ -570,7 +574,7 @@ impl str {
570574
core_str::StrExt::split_at_mut(self, mid)
571575
}
572576

573-
/// Returns an iterator over the `char`s of a string slice.
577+
/// Returns an iterator over the [`char`]s of a string slice.
574578
///
575579
/// As a string slice consists of valid UTF-8, we can iterate through a
576580
/// string slice by [`char`]. This method returns such an iterator.
@@ -1657,13 +1661,13 @@ impl str {
16571661

16581662
/// Parses this string slice into another type.
16591663
///
1660-
/// Because `parse()` is so general, it can cause problems with type
1661-
/// inference. As such, `parse()` is one of the few times you'll see
1664+
/// Because `parse` is so general, it can cause problems with type
1665+
/// inference. As such, `parse` is one of the few times you'll see
16621666
/// the syntax affectionately known as the 'turbofish': `::<>`. This
16631667
/// helps the inference algorithm understand specifically which type
16641668
/// you're trying to parse into.
16651669
///
1666-
/// `parse()` can parse any type that implements the [`FromStr`] trait.
1670+
/// `parse` can parse any type that implements the [`FromStr`] trait.
16671671
///
16681672
/// [`FromStr`]: str/trait.FromStr.html
16691673
///
@@ -1746,7 +1750,7 @@ impl str {
17461750
///
17471751
/// `replacen` creates a new [`String`], and copies the data from this string slice into it.
17481752
/// While doing so, it attempts to find matches of a pattern. If it finds any, it
1749-
/// replaces them with the replacement string slice at most `N` times.
1753+
/// replaces them with the replacement string slice at most `count` times.
17501754
///
17511755
/// [`String`]: string/struct.String.html
17521756
///
@@ -1892,33 +1896,40 @@ impl str {
18921896
return s;
18931897
}
18941898

1895-
/// Escapes each char in `s` with `char::escape_debug`.
1899+
/// Escapes each char in `s` with [`char::escape_debug`].
1900+
///
1901+
/// [`char::escape_debug`]: primitive.char.html#method.escape_debug
18961902
#[unstable(feature = "str_escape",
18971903
reason = "return type may change to be an iterator",
18981904
issue = "27791")]
18991905
pub fn escape_debug(&self) -> String {
19001906
self.chars().flat_map(|c| c.escape_debug()).collect()
19011907
}
19021908

1903-
/// Escapes each char in `s` with `char::escape_default`.
1909+
/// Escapes each char in `s` with [`char::escape_default`].
1910+
///
1911+
/// [`char::escape_default`]: primitive.char.html#method.escape_default
19041912
#[unstable(feature = "str_escape",
19051913
reason = "return type may change to be an iterator",
19061914
issue = "27791")]
19071915
pub fn escape_default(&self) -> String {
19081916
self.chars().flat_map(|c| c.escape_default()).collect()
19091917
}
19101918

1911-
/// Escapes each char in `s` with `char::escape_unicode`.
1919+
/// Escapes each char in `s` with [`char::escape_unicode`].
1920+
///
1921+
/// [`char::escape_unicode`]: primitive.char.html#method.escape_unicode
19121922
#[unstable(feature = "str_escape",
19131923
reason = "return type may change to be an iterator",
19141924
issue = "27791")]
19151925
pub fn escape_unicode(&self) -> String {
19161926
self.chars().flat_map(|c| c.escape_unicode()).collect()
19171927
}
19181928

1919-
/// Converts a `Box<str>` into a [`String`] without copying or allocating.
1929+
/// Converts a [`Box<str>`] into a [`String`] without copying or allocating.
19201930
///
19211931
/// [`String`]: string/struct.String.html
1932+
/// [`Box<str>`]: boxed/struct.Box.html
19221933
///
19231934
/// # Examples
19241935
///

src/libstd/primitive_docs.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ mod prim_slice { }
406406
///
407407
/// This documentation describes a number of methods and trait implementations
408408
/// on the `str` type. For technical reasons, there is additional, separate
409-
/// documentation in [the `std::str` module](str/index.html) as well.
409+
/// documentation in the [`std::str`](str/index.html) module as well.
410410
///
411411
/// # Examples
412412
///
@@ -425,7 +425,7 @@ mod prim_slice { }
425425
/// # Representation
426426
///
427427
/// A `&str` is made up of two components: a pointer to some bytes, and a
428-
/// length. You can look at these with the [`.as_ptr`] and [`len`] methods:
428+
/// length. You can look at these with the [`as_ptr`] and [`len`] methods:
429429
///
430430
/// ```
431431
/// use std::slice;
@@ -452,11 +452,11 @@ mod prim_slice { }
452452
/// assert_eq!(s, Ok(story));
453453
/// ```
454454
///
455-
/// [`.as_ptr`]: #method.as_ptr
455+
/// [`as_ptr`]: #method.as_ptr
456456
/// [`len`]: #method.len
457457
///
458458
/// Note: This example shows the internals of `&str`. `unsafe` should not be
459-
/// used to get a string slice under normal circumstances. Use `.as_slice()`
459+
/// used to get a string slice under normal circumstances. Use `as_slice`
460460
/// instead.
461461
#[stable(feature = "rust1", since = "1.0.0")]
462462
mod prim_str { }

0 commit comments

Comments
 (0)