Skip to content

Commit ed7b6c3

Browse files
committed
Minor nits in primitive str
1 parent ad36c2f commit ed7b6c3

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
@@ -318,8 +318,10 @@ impl str {
318318

319319
/// Returns a subslice of `str`.
320320
///
321-
/// This is the non-panicking alternative to indexing the `str`. Returns `None` whenever
322-
/// equivalent indexing operation would panic.
321+
/// This is the non-panicking alternative to indexing the `str`. Returns
322+
/// [`None`] whenever equivalent indexing operation would panic.
323+
///
324+
/// [`None`]: option/enum.Option.html#variant.None
323325
///
324326
/// # Examples
325327
///
@@ -339,8 +341,10 @@ impl str {
339341

340342
/// Returns a mutable subslice of `str`.
341343
///
342-
/// This is the non-panicking alternative to indexing the `str`. Returns `None` whenever
343-
/// equivalent indexing operation would panic.
344+
/// This is the non-panicking alternative to indexing the `str`. Returns
345+
/// [`None`] whenever equivalent indexing operation would panic.
346+
///
347+
/// [`None`]: option/enum.Option.html#variant.None
344348
///
345349
/// # Examples
346350
///
@@ -563,7 +567,7 @@ impl str {
563567
core_str::StrExt::split_at_mut(self, mid)
564568
}
565569

566-
/// Returns an iterator over the `char`s of a string slice.
570+
/// Returns an iterator over the [`char`]s of a string slice.
567571
///
568572
/// As a string slice consists of valid UTF-8, we can iterate through a
569573
/// string slice by [`char`]. This method returns such an iterator.
@@ -1650,13 +1654,13 @@ impl str {
16501654

16511655
/// Parses this string slice into another type.
16521656
///
1653-
/// Because `parse()` is so general, it can cause problems with type
1654-
/// inference. As such, `parse()` is one of the few times you'll see
1657+
/// Because `parse` is so general, it can cause problems with type
1658+
/// inference. As such, `parse` is one of the few times you'll see
16551659
/// the syntax affectionately known as the 'turbofish': `::<>`. This
16561660
/// helps the inference algorithm understand specifically which type
16571661
/// you're trying to parse into.
16581662
///
1659-
/// `parse()` can parse any type that implements the [`FromStr`] trait.
1663+
/// `parse` can parse any type that implements the [`FromStr`] trait.
16601664
///
16611665
/// [`FromStr`]: str/trait.FromStr.html
16621666
///
@@ -1739,7 +1743,7 @@ impl str {
17391743
///
17401744
/// `replacen` creates a new [`String`], and copies the data from this string slice into it.
17411745
/// While doing so, it attempts to find matches of a pattern. If it finds any, it
1742-
/// replaces them with the replacement string slice at most `N` times.
1746+
/// replaces them with the replacement string slice at most `count` times.
17431747
///
17441748
/// [`String`]: string/struct.String.html
17451749
///
@@ -1885,33 +1889,40 @@ impl str {
18851889
return s;
18861890
}
18871891

1888-
/// Escapes each char in `s` with `char::escape_debug`.
1892+
/// Escapes each char in `s` with [`char::escape_debug`].
1893+
///
1894+
/// [`char::escape_debug`]: primitive.char.html#method.escape_debug
18891895
#[unstable(feature = "str_escape",
18901896
reason = "return type may change to be an iterator",
18911897
issue = "27791")]
18921898
pub fn escape_debug(&self) -> String {
18931899
self.chars().flat_map(|c| c.escape_debug()).collect()
18941900
}
18951901

1896-
/// Escapes each char in `s` with `char::escape_default`.
1902+
/// Escapes each char in `s` with [`char::escape_default`].
1903+
///
1904+
/// [`char::escape_default`]: primitive.char.html#method.escape_default
18971905
#[unstable(feature = "str_escape",
18981906
reason = "return type may change to be an iterator",
18991907
issue = "27791")]
19001908
pub fn escape_default(&self) -> String {
19011909
self.chars().flat_map(|c| c.escape_default()).collect()
19021910
}
19031911

1904-
/// Escapes each char in `s` with `char::escape_unicode`.
1912+
/// Escapes each char in `s` with [`char::escape_unicode`].
1913+
///
1914+
/// [`char::escape_unicode`]: primitive.char.html#method.escape_unicode
19051915
#[unstable(feature = "str_escape",
19061916
reason = "return type may change to be an iterator",
19071917
issue = "27791")]
19081918
pub fn escape_unicode(&self) -> String {
19091919
self.chars().flat_map(|c| c.escape_unicode()).collect()
19101920
}
19111921

1912-
/// Converts a `Box<str>` into a [`String`] without copying or allocating.
1922+
/// Converts a [`Box<str>`] into a [`String`] without copying or allocating.
19131923
///
19141924
/// [`String`]: string/struct.String.html
1925+
/// [`Box<str>`]: boxed/struct.Box.html
19151926
///
19161927
/// # Examples
19171928
///

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)