Rollup merge of #74485 - Manishearth:more-intra-doc, r=jyn514
More intra-doc links, add explicit exception list to linkchecker Fixes the broken links behind #32553 Progress on #32130 and #32129 except for a small number of links. Instead of whitelisting entire files, I've changed the code to whitelist specific links in specific files, and added a comment requesting people explain the reasons they add exceptions. I'm not sure if we should close those issues in favor of the already filed intra-doc link issues.
This commit is contained in:
commit
1636961a0e
@ -47,9 +47,9 @@
|
||||
/// any other key, as determined by the [`Ord`] trait, changes while it is in the map. This is
|
||||
/// normally only possible through [`Cell`], [`RefCell`], global state, I/O, or unsafe code.
|
||||
///
|
||||
/// [`Ord`]: ../../std/cmp/trait.Ord.html
|
||||
/// [`Cell`]: ../../std/cell/struct.Cell.html
|
||||
/// [`RefCell`]: ../../std/cell/struct.RefCell.html
|
||||
/// [`Ord`]: core::cmp::Ord
|
||||
/// [`Cell`]: core::cell::Cell
|
||||
/// [`RefCell`]: core::cell::RefCell
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
@ -256,8 +256,7 @@ fn replace(&mut self, key: K) -> Option<K> {
|
||||
/// This `struct` is created by the [`iter`] method on [`BTreeMap`]. See its
|
||||
/// documentation for more.
|
||||
///
|
||||
/// [`iter`]: struct.BTreeMap.html#method.iter
|
||||
/// [`BTreeMap`]: struct.BTreeMap.html
|
||||
/// [`iter`]: BTreeMap::iter
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct Iter<'a, K: 'a, V: 'a> {
|
||||
range: Range<'a, K, V>,
|
||||
@ -276,8 +275,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
/// This `struct` is created by the [`iter_mut`] method on [`BTreeMap`]. See its
|
||||
/// documentation for more.
|
||||
///
|
||||
/// [`iter_mut`]: struct.BTreeMap.html#method.iter_mut
|
||||
/// [`BTreeMap`]: struct.BTreeMap.html
|
||||
/// [`iter_mut`]: BTreeMap::iter_mut
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[derive(Debug)]
|
||||
pub struct IterMut<'a, K: 'a, V: 'a> {
|
||||
@ -290,8 +288,7 @@ pub struct IterMut<'a, K: 'a, V: 'a> {
|
||||
/// This `struct` is created by the [`into_iter`] method on [`BTreeMap`]
|
||||
/// (provided by the `IntoIterator` trait). See its documentation for more.
|
||||
///
|
||||
/// [`into_iter`]: struct.BTreeMap.html#method.into_iter
|
||||
/// [`BTreeMap`]: struct.BTreeMap.html
|
||||
/// [`into_iter`]: IntoIterator::into_iter
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct IntoIter<K, V> {
|
||||
front: Option<Handle<NodeRef<marker::Owned, K, V, marker::Leaf>, marker::Edge>>,
|
||||
@ -315,8 +312,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
/// This `struct` is created by the [`keys`] method on [`BTreeMap`]. See its
|
||||
/// documentation for more.
|
||||
///
|
||||
/// [`keys`]: struct.BTreeMap.html#method.keys
|
||||
/// [`BTreeMap`]: struct.BTreeMap.html
|
||||
/// [`keys`]: BTreeMap::keys
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct Keys<'a, K: 'a, V: 'a> {
|
||||
inner: Iter<'a, K, V>,
|
||||
@ -334,8 +330,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
/// This `struct` is created by the [`values`] method on [`BTreeMap`]. See its
|
||||
/// documentation for more.
|
||||
///
|
||||
/// [`values`]: struct.BTreeMap.html#method.values
|
||||
/// [`BTreeMap`]: struct.BTreeMap.html
|
||||
/// [`values`]: BTreeMap::values
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct Values<'a, K: 'a, V: 'a> {
|
||||
inner: Iter<'a, K, V>,
|
||||
@ -353,8 +348,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
/// This `struct` is created by the [`values_mut`] method on [`BTreeMap`]. See its
|
||||
/// documentation for more.
|
||||
///
|
||||
/// [`values_mut`]: struct.BTreeMap.html#method.values_mut
|
||||
/// [`BTreeMap`]: struct.BTreeMap.html
|
||||
/// [`values_mut`]: BTreeMap::values_mut
|
||||
#[stable(feature = "map_values_mut", since = "1.10.0")]
|
||||
#[derive(Debug)]
|
||||
pub struct ValuesMut<'a, K: 'a, V: 'a> {
|
||||
@ -366,8 +360,7 @@ pub struct ValuesMut<'a, K: 'a, V: 'a> {
|
||||
/// This `struct` is created by the [`range`] method on [`BTreeMap`]. See its
|
||||
/// documentation for more.
|
||||
///
|
||||
/// [`range`]: struct.BTreeMap.html#method.range
|
||||
/// [`BTreeMap`]: struct.BTreeMap.html
|
||||
/// [`range`]: BTreeMap::range
|
||||
#[stable(feature = "btree_range", since = "1.17.0")]
|
||||
pub struct Range<'a, K: 'a, V: 'a> {
|
||||
front: Option<Handle<NodeRef<marker::Immut<'a>, K, V, marker::Leaf>, marker::Edge>>,
|
||||
@ -386,8 +379,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
/// This `struct` is created by the [`range_mut`] method on [`BTreeMap`]. See its
|
||||
/// documentation for more.
|
||||
///
|
||||
/// [`range_mut`]: struct.BTreeMap.html#method.range_mut
|
||||
/// [`BTreeMap`]: struct.BTreeMap.html
|
||||
/// [`range_mut`]: BTreeMap::range_mut
|
||||
#[stable(feature = "btree_range", since = "1.17.0")]
|
||||
pub struct RangeMut<'a, K: 'a, V: 'a> {
|
||||
front: Option<Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, marker::Edge>>,
|
||||
@ -412,8 +404,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
///
|
||||
/// This `enum` is constructed from the [`entry`] method on [`BTreeMap`].
|
||||
///
|
||||
/// [`BTreeMap`]: struct.BTreeMap.html
|
||||
/// [`entry`]: struct.BTreeMap.html#method.entry
|
||||
/// [`entry`]: BTreeMap::entry
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub enum Entry<'a, K: 'a, V: 'a> {
|
||||
/// A vacant entry.
|
||||
|
@ -22,9 +22,9 @@
|
||||
/// to any other item, as determined by the [`Ord`] trait, changes while it is in the set. This is
|
||||
/// normally only possible through [`Cell`], [`RefCell`], global state, I/O, or unsafe code.
|
||||
///
|
||||
/// [`Ord`]: ../../std/cmp/trait.Ord.html
|
||||
/// [`Cell`]: ../../std/cell/struct.Cell.html
|
||||
/// [`RefCell`]: ../../std/cell/struct.RefCell.html
|
||||
/// [`Ord`]: core::cmp::Ord
|
||||
/// [`Cell`]: core::cell::Cell
|
||||
/// [`RefCell`]: core::cell::RefCell
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -240,8 +240,6 @@ pub fn into_boxed_bytes(self: Box<str>) -> Box<[u8]> {
|
||||
/// While doing so, it attempts to find matches of a pattern. If it finds any, it
|
||||
/// replaces them with the replacement string slice.
|
||||
///
|
||||
/// [`String`]: string/struct.String.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
@ -280,8 +278,6 @@ pub fn replace<'a, P: Pattern<'a>>(&'a self, from: P, to: &str) -> String {
|
||||
/// While doing so, it attempts to find matches of a pattern. If it finds any, it
|
||||
/// replaces them with the replacement string slice at most `count` times.
|
||||
///
|
||||
/// [`String`]: string/struct.String.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
@ -324,8 +320,6 @@ pub fn replacen<'a, P: Pattern<'a>>(&'a self, pat: P, to: &str, count: usize) ->
|
||||
/// the case, this function returns a [`String`] instead of modifying the
|
||||
/// parameter in-place.
|
||||
///
|
||||
/// [`String`]: string/struct.String.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
@ -411,8 +405,6 @@ fn case_ignoreable_then_cased<I: Iterator<Item = char>>(iter: I) -> bool {
|
||||
/// the case, this function returns a [`String`] instead of modifying the
|
||||
/// parameter in-place.
|
||||
///
|
||||
/// [`String`]: string/struct.String.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
@ -459,8 +451,7 @@ pub fn to_uppercase(&self) -> String {
|
||||
|
||||
/// Converts a [`Box<str>`] into a [`String`] without copying or allocating.
|
||||
///
|
||||
/// [`String`]: string/struct.String.html
|
||||
/// [`Box<str>`]: boxed/struct.Box.html
|
||||
/// [`Box<str>`]: Box
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
@ -485,8 +476,6 @@ pub fn into_string(self: Box<str>) -> String {
|
||||
///
|
||||
/// This function will panic if the capacity would overflow.
|
||||
///
|
||||
/// [`String`]: string/struct.String.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
@ -525,7 +514,7 @@ pub fn repeat(&self, n: usize) -> String {
|
||||
/// assert_eq!("GRüßE, JüRGEN ❤", s.to_ascii_uppercase());
|
||||
/// ```
|
||||
///
|
||||
/// [`make_ascii_uppercase`]: #method.make_ascii_uppercase
|
||||
/// [`make_ascii_uppercase`]: str::make_ascii_uppercase
|
||||
/// [`to_uppercase`]: #method.to_uppercase
|
||||
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
|
||||
#[inline]
|
||||
@ -555,7 +544,7 @@ pub fn to_ascii_uppercase(&self) -> String {
|
||||
/// assert_eq!("grüße, jürgen ❤", s.to_ascii_lowercase());
|
||||
/// ```
|
||||
///
|
||||
/// [`make_ascii_lowercase`]: #method.make_ascii_lowercase
|
||||
/// [`make_ascii_lowercase`]: str::make_ascii_lowercase
|
||||
/// [`to_lowercase`]: #method.to_lowercase
|
||||
#[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
|
||||
#[inline]
|
||||
|
@ -4,8 +4,6 @@
|
||||
//! [`ToString`]s, and several error types that may result from working with
|
||||
//! [`String`]s.
|
||||
//!
|
||||
//! [`ToString`]: trait.ToString.html
|
||||
//!
|
||||
//! # Examples
|
||||
//!
|
||||
//! There are multiple ways to create a new [`String`] from a string literal:
|
||||
@ -20,8 +18,6 @@
|
||||
//! You can create a new [`String`] from an existing one by concatenating with
|
||||
//! `+`:
|
||||
//!
|
||||
//! [`String`]: struct.String.html
|
||||
//!
|
||||
//! ```
|
||||
//! let s = "Hello".to_string();
|
||||
//!
|
||||
@ -67,11 +63,11 @@
|
||||
/// contents of the string. It has a close relationship with its borrowed
|
||||
/// counterpart, the primitive [`str`].
|
||||
///
|
||||
/// [`str`]: ../../std/primitive.str.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// You can create a `String` from a literal string with [`String::from`]:
|
||||
/// You can create a `String` from [a literal string][str] with [`String::from`]:
|
||||
///
|
||||
/// [`String::from`]: From::from
|
||||
///
|
||||
/// ```
|
||||
/// let hello = String::from("Hello, world!");
|
||||
@ -87,10 +83,8 @@
|
||||
/// hello.push_str("orld!");
|
||||
/// ```
|
||||
///
|
||||
/// [`String::from`]: #method.from
|
||||
/// [`char`]: ../../std/primitive.char.html
|
||||
/// [`push`]: #method.push
|
||||
/// [`push_str`]: #method.push_str
|
||||
/// [`push`]: String::push
|
||||
/// [`push_str`]: String::push_str
|
||||
///
|
||||
/// If you have a vector of UTF-8 bytes, you can create a `String` from it with
|
||||
/// the [`from_utf8`] method:
|
||||
@ -105,7 +99,7 @@
|
||||
/// assert_eq!("💖", sparkle_heart);
|
||||
/// ```
|
||||
///
|
||||
/// [`from_utf8`]: #method.from_utf8
|
||||
/// [`from_utf8`]: String::from_utf8
|
||||
///
|
||||
/// # UTF-8
|
||||
///
|
||||
@ -128,8 +122,8 @@
|
||||
/// The [`bytes`] and [`chars`] methods return iterators over the first
|
||||
/// two, respectively.
|
||||
///
|
||||
/// [`bytes`]: #method.bytes
|
||||
/// [`chars`]: #method.chars
|
||||
/// [`bytes`]: str::bytes
|
||||
/// [`chars`]: str::chars
|
||||
///
|
||||
/// # Deref
|
||||
///
|
||||
@ -215,9 +209,9 @@
|
||||
/// assert_eq!(String::from("Once upon a time..."), s);
|
||||
/// ```
|
||||
///
|
||||
/// [`as_ptr`]: #method.as_ptr
|
||||
/// [`len`]: #method.len
|
||||
/// [`capacity`]: #method.capacity
|
||||
/// [`as_ptr`]: str::as_ptr
|
||||
/// [`len`]: String::len
|
||||
/// [`capacity`]: String::capacity
|
||||
///
|
||||
/// If a `String` has enough capacity, adding elements to it will not
|
||||
/// re-allocate. For example, consider this program:
|
||||
@ -259,7 +253,7 @@
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// [`with_capacity`]: #method.with_capacity
|
||||
/// [`with_capacity`]: String::with_capacity
|
||||
///
|
||||
/// We end up with a different output:
|
||||
///
|
||||
@ -274,9 +268,9 @@
|
||||
///
|
||||
/// Here, there's no need to allocate more memory inside the loop.
|
||||
///
|
||||
/// [`&str`]: ../../std/primitive.str.html
|
||||
/// [`Deref`]: ../../std/ops/trait.Deref.html
|
||||
/// [`as_str()`]: struct.String.html#method.as_str
|
||||
/// [`&str`]: str
|
||||
/// [`Deref`]: core::ops::Deref
|
||||
/// [`as_str()`]: String::as_str
|
||||
#[derive(PartialOrd, Eq, Ord)]
|
||||
#[cfg_attr(not(test), rustc_diagnostic_item = "string_type")]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -291,20 +285,18 @@ pub struct String {
|
||||
/// [`into_bytes`] method will give back the byte vector that was used in the
|
||||
/// conversion attempt.
|
||||
///
|
||||
/// [`from_utf8`]: struct.String.html#method.from_utf8
|
||||
/// [`String`]: struct.String.html
|
||||
/// [`into_bytes`]: struct.FromUtf8Error.html#method.into_bytes
|
||||
/// [`from_utf8`]: String::from_utf8
|
||||
/// [`into_bytes`]: FromUtf8Error::into_bytes
|
||||
///
|
||||
/// The [`Utf8Error`] type provided by [`std::str`] represents an error that may
|
||||
/// occur when converting a slice of [`u8`]s to a [`&str`]. In this sense, it's
|
||||
/// an analogue to `FromUtf8Error`, and you can get one from a `FromUtf8Error`
|
||||
/// through the [`utf8_error`] method.
|
||||
///
|
||||
/// [`Utf8Error`]: ../../std/str/struct.Utf8Error.html
|
||||
/// [`std::str`]: ../../std/str/index.html
|
||||
/// [`u8`]: ../../std/primitive.u8.html
|
||||
/// [`&str`]: ../../std/primitive.str.html
|
||||
/// [`utf8_error`]: #method.utf8_error
|
||||
/// [`Utf8Error`]: core::str::Utf8Error
|
||||
/// [`std::str`]: core::str
|
||||
/// [`&str`]: str
|
||||
/// [`utf8_error`]: Self::utf8_error
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
@ -330,9 +322,7 @@ pub struct FromUtf8Error {
|
||||
///
|
||||
/// This type is the error type for the [`from_utf16`] method on [`String`].
|
||||
///
|
||||
/// [`from_utf16`]: struct.String.html#method.from_utf16
|
||||
/// [`String`]: struct.String.html
|
||||
///
|
||||
/// [`from_utf16`]: String::from_utf16
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
@ -358,7 +348,7 @@ impl String {
|
||||
/// consider the [`with_capacity`] method to prevent excessive
|
||||
/// re-allocation.
|
||||
///
|
||||
/// [`with_capacity`]: #method.with_capacity
|
||||
/// [`with_capacity`]: String::with_capacity
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
@ -383,12 +373,12 @@ pub const fn new() -> String {
|
||||
/// appending a bunch of data to the `String`, reducing the number of
|
||||
/// reallocations it needs to do.
|
||||
///
|
||||
/// [`capacity`]: #method.capacity
|
||||
/// [`capacity`]: String::capacity
|
||||
///
|
||||
/// If the given capacity is `0`, no allocation will occur, and this method
|
||||
/// is identical to the [`new`] method.
|
||||
///
|
||||
/// [`new`]: #method.new
|
||||
/// [`new`]: String::new
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
@ -479,15 +469,10 @@ pub fn from_str(_: &str) -> String {
|
||||
/// See the docs for [`FromUtf8Error`] for more details on what you can do
|
||||
/// with this error.
|
||||
///
|
||||
/// [`from_utf8_unchecked`]: struct.String.html#method.from_utf8_unchecked
|
||||
/// [`String`]: struct.String.html
|
||||
/// [`u8`]: ../../std/primitive.u8.html
|
||||
/// [`Vec<u8>`]: ../../std/vec/struct.Vec.html
|
||||
/// [`&str`]: ../../std/primitive.str.html
|
||||
/// [`str::from_utf8`]: ../../std/str/fn.from_utf8.html
|
||||
/// [`into_bytes`]: struct.String.html#method.into_bytes
|
||||
/// [`FromUtf8Error`]: struct.FromUtf8Error.html
|
||||
/// [`Err`]: ../../std/result/enum.Result.html#variant.Err
|
||||
/// [`from_utf8_unchecked`]: String::from_utf8_unchecked
|
||||
/// [`Vec<u8>`]: crate::vec::Vec
|
||||
/// [`&str`]: str
|
||||
/// [`into_bytes`]: String::into_bytes
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn from_utf8(vec: Vec<u8>) -> Result<String, FromUtf8Error> {
|
||||
@ -506,16 +491,15 @@ pub fn from_utf8(vec: Vec<u8>) -> Result<String, FromUtf8Error> {
|
||||
/// `from_utf8_lossy()` will replace any invalid UTF-8 sequences with
|
||||
/// [`U+FFFD REPLACEMENT CHARACTER`][U+FFFD], which looks like this: <20>
|
||||
///
|
||||
/// [`u8`]: ../../std/primitive.u8.html
|
||||
/// [byteslice]: ../../std/primitive.slice.html
|
||||
/// [U+FFFD]: ../char/constant.REPLACEMENT_CHARACTER.html
|
||||
/// [U+FFFD]: core::char::REPLACEMENT_CHARACTER
|
||||
///
|
||||
/// If you are sure that the byte slice is valid UTF-8, and you don't want
|
||||
/// to incur the overhead of the conversion, there is an unsafe version
|
||||
/// of this function, [`from_utf8_unchecked`], which has the same behavior
|
||||
/// but skips the checks.
|
||||
///
|
||||
/// [`from_utf8_unchecked`]: struct.String.html#method.from_utf8_unchecked
|
||||
/// [`from_utf8_unchecked`]: String::from_utf8_unchecked
|
||||
///
|
||||
/// This function returns a [`Cow<'a, str>`]. If our byte slice is invalid
|
||||
/// UTF-8, then we need to insert the replacement characters, which will
|
||||
@ -523,7 +507,7 @@ pub fn from_utf8(vec: Vec<u8>) -> Result<String, FromUtf8Error> {
|
||||
/// it's already valid UTF-8, we don't need a new allocation. This return
|
||||
/// type allows us to handle both cases.
|
||||
///
|
||||
/// [`Cow<'a, str>`]: ../../std/borrow/enum.Cow.html
|
||||
/// [`Cow<'a, str>`]: crate::borrow::Cow
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
@ -583,8 +567,6 @@ pub fn from_utf8_lossy(v: &[u8]) -> Cow<'_, str> {
|
||||
/// Decode a UTF-16 encoded vector `v` into a `String`, returning [`Err`]
|
||||
/// if `v` contains any invalid data.
|
||||
///
|
||||
/// [`Err`]: ../../std/result/enum.Result.html#variant.Err
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
@ -623,9 +605,9 @@ pub fn from_utf16(v: &[u16]) -> Result<String, FromUtf16Error> {
|
||||
/// `from_utf16_lossy` returns a `String` since the UTF-16 to UTF-8
|
||||
/// conversion requires a memory allocation.
|
||||
///
|
||||
/// [`from_utf8_lossy`]: #method.from_utf8_lossy
|
||||
/// [`Cow<'a, str>`]: ../borrow/enum.Cow.html
|
||||
/// [U+FFFD]: ../char/constant.REPLACEMENT_CHARACTER.html
|
||||
/// [`from_utf8_lossy`]: String::from_utf8_lossy
|
||||
/// [`Cow<'a, str>`]: crate::borrow::Cow
|
||||
/// [U+FFFD]: core::char::REPLACEMENT_CHARACTER
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
@ -659,7 +641,7 @@ pub fn from_utf16_lossy(v: &[u16]) -> String {
|
||||
/// into a `String` with the [`from_raw_parts`] function, allowing
|
||||
/// the destructor to perform the cleanup.
|
||||
///
|
||||
/// [`from_raw_parts`]: #method.from_raw_parts
|
||||
/// [`from_raw_parts`]: String::from_raw_parts
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
@ -732,7 +714,7 @@ pub unsafe fn from_raw_parts(buf: *mut u8, length: usize, capacity: usize) -> St
|
||||
///
|
||||
/// See the safe version, [`from_utf8`], for more details.
|
||||
///
|
||||
/// [`from_utf8`]: struct.String.html#method.from_utf8
|
||||
/// [`from_utf8`]: String::from_utf8
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
@ -867,8 +849,7 @@ pub fn capacity(&self) -> usize {
|
||||
///
|
||||
/// Panics if the new capacity overflows [`usize`].
|
||||
///
|
||||
/// [`reserve_exact`]: struct.String.html#method.reserve_exact
|
||||
/// [`usize`]: ../../std/primitive.usize.html
|
||||
/// [`reserve_exact`]: String::reserve_exact
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
@ -911,7 +892,7 @@ pub fn reserve(&mut self, additional: usize) {
|
||||
/// Consider using the [`reserve`] method unless you absolutely know
|
||||
/// better than the allocator.
|
||||
///
|
||||
/// [`reserve`]: #method.reserve
|
||||
/// [`reserve`]: String::reserve
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
@ -1076,8 +1057,6 @@ pub fn shrink_to(&mut self, min_capacity: usize) {
|
||||
|
||||
/// Appends the given [`char`] to the end of this `String`.
|
||||
///
|
||||
/// [`char`]: ../../std/primitive.char.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
@ -1104,7 +1083,7 @@ pub fn push(&mut self, ch: char) {
|
||||
///
|
||||
/// The inverse of this method is [`from_utf8`].
|
||||
///
|
||||
/// [`from_utf8`]: #method.from_utf8
|
||||
/// [`from_utf8`]: String::from_utf8
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
@ -1133,8 +1112,6 @@ pub fn as_bytes(&self) -> &[u8] {
|
||||
///
|
||||
/// Panics if `new_len` does not lie on a [`char`] boundary.
|
||||
///
|
||||
/// [`char`]: ../../std/primitive.char.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
@ -1159,8 +1136,6 @@ pub fn truncate(&mut self, new_len: usize) {
|
||||
///
|
||||
/// Returns [`None`] if this `String` is empty.
|
||||
///
|
||||
/// [`None`]: ../../std/option/enum.Option.html#variant.None
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
@ -1195,8 +1170,6 @@ pub fn pop(&mut self) -> Option<char> {
|
||||
/// Panics if `idx` is larger than or equal to the `String`'s length,
|
||||
/// or if it does not lie on a [`char`] boundary.
|
||||
///
|
||||
/// [`char`]: ../../std/primitive.char.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
@ -1297,8 +1270,6 @@ pub fn retain<F>(&mut self, mut f: F)
|
||||
/// Panics if `idx` is larger than the `String`'s length, or if it does not
|
||||
/// lie on a [`char`] boundary.
|
||||
///
|
||||
/// [`char`]: ../../std/primitive.char.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
@ -1346,8 +1317,6 @@ unsafe fn insert_bytes(&mut self, idx: usize, bytes: &[u8]) {
|
||||
/// Panics if `idx` is larger than the `String`'s length, or if it does not
|
||||
/// lie on a [`char`] boundary.
|
||||
///
|
||||
/// [`char`]: ../../std/primitive.char.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
@ -1507,8 +1476,6 @@ pub fn clear(&mut self) {
|
||||
/// Panics if the starting point or end point do not lie on a [`char`]
|
||||
/// boundary, or if they're out of bounds.
|
||||
///
|
||||
/// [`char`]: ../../std/primitive.char.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
@ -1567,9 +1534,6 @@ pub fn drain<R>(&mut self, range: R) -> Drain<'_>
|
||||
/// Panics if the starting point or end point do not lie on a [`char`]
|
||||
/// boundary, or if they're out of bounds.
|
||||
///
|
||||
/// [`char`]: ../../std/primitive.char.html
|
||||
/// [`Vec::splice`]: ../../std/vec/struct.Vec.html#method.splice
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
@ -1610,9 +1574,6 @@ pub fn replace_range<R>(&mut self, range: R, replace_with: &str)
|
||||
///
|
||||
/// This will drop any excess capacity.
|
||||
///
|
||||
/// [`Box`]: ../../std/boxed/struct.Box.html
|
||||
/// [`str`]: ../../std/primitive.str.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// Basic usage:
|
||||
@ -1680,10 +1641,8 @@ pub fn into_bytes(self) -> Vec<u8> {
|
||||
/// an analogue to `FromUtf8Error`. See its documentation for more details
|
||||
/// on using it.
|
||||
///
|
||||
/// [`Utf8Error`]: ../../std/str/struct.Utf8Error.html
|
||||
/// [`std::str`]: ../../std/str/index.html
|
||||
/// [`u8`]: ../../std/primitive.u8.html
|
||||
/// [`&str`]: ../../std/primitive.str.html
|
||||
/// [`std::str`]: core::str
|
||||
/// [`&str`]: str
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
@ -2187,7 +2146,7 @@ fn deref_mut(&mut self) -> &mut str {
|
||||
///
|
||||
/// This alias exists for backwards compatibility, and may be eventually deprecated.
|
||||
///
|
||||
/// [`Infallible`]: ../../core/convert/enum.Infallible.html
|
||||
/// [`Infallible`]: core::convert::Infallible
|
||||
#[stable(feature = "str_parse_error", since = "1.5.0")]
|
||||
pub type ParseError = core::convert::Infallible;
|
||||
|
||||
@ -2207,7 +2166,7 @@ fn from_str(s: &str) -> Result<String, Self::Err> {
|
||||
/// [`Display`] should be implemented instead, and you get the `ToString`
|
||||
/// implementation for free.
|
||||
///
|
||||
/// [`Display`]: ../../std/fmt/trait.Display.html
|
||||
/// [`Display`]: fmt::Display
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub trait ToString {
|
||||
/// Converts the given value to a `String`.
|
||||
@ -2465,8 +2424,7 @@ fn write_char(&mut self, c: char) -> fmt::Result {
|
||||
/// This struct is created by the [`drain`] method on [`String`]. See its
|
||||
/// documentation for more.
|
||||
///
|
||||
/// [`drain`]: struct.String.html#method.drain
|
||||
/// [`String`]: struct.String.html
|
||||
/// [`drain`]: String::drain
|
||||
#[stable(feature = "drain", since = "1.6.0")]
|
||||
pub struct Drain<'a> {
|
||||
/// Will be used as &'a mut String in the destructor
|
||||
|
@ -4,7 +4,7 @@
|
||||
//!
|
||||
//! For more details, see the [`std::str`] module.
|
||||
//!
|
||||
//! [`std::str`]: ../../std/str/index.html
|
||||
//! [`std::str`]: self
|
||||
|
||||
#![stable(feature = "rust1", since = "1.0.0")]
|
||||
|
||||
@ -163,13 +163,11 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
/// Errors which can occur when attempting to interpret a sequence of [`u8`]
|
||||
/// as a string.
|
||||
///
|
||||
/// [`u8`]: ../../std/primitive.u8.html
|
||||
///
|
||||
/// As such, the `from_utf8` family of functions and methods for both [`String`]s
|
||||
/// and [`&str`]s make use of this error, for example.
|
||||
///
|
||||
/// [`String`]: ../../std/string/struct.String.html#method.from_utf8
|
||||
/// [`&str`]: ../../std/str/fn.from_utf8.html
|
||||
/// [`&str`]: from_utf8
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -148,14 +148,11 @@
|
||||
/// The easiest way to use `HashMap` with a custom key type is to derive [`Eq`] and [`Hash`].
|
||||
/// We must also derive [`PartialEq`].
|
||||
///
|
||||
/// [`Eq`]: ../../std/cmp/trait.Eq.html
|
||||
/// [`Hash`]: ../../std/hash/trait.Hash.html
|
||||
/// [`PartialEq`]: ../../std/cmp/trait.PartialEq.html
|
||||
/// [`RefCell`]: ../../std/cell/struct.RefCell.html
|
||||
/// [`Cell`]: ../../std/cell/struct.Cell.html
|
||||
/// [`default`]: #method.default
|
||||
/// [`with_hasher`]: #method.with_hasher
|
||||
/// [`with_capacity_and_hasher`]: #method.with_capacity_and_hasher
|
||||
/// [`RefCell`]: crate::cell::RefCell
|
||||
/// [`Cell`]: crate::cell::Cell
|
||||
/// [`default`]: Default::default
|
||||
/// [`with_hasher`]: Self::with_hasher
|
||||
/// [`with_capacity_and_hasher`]: Self::with_capacity_and_hasher
|
||||
/// [`fnv`]: https://crates.io/crates/fnv
|
||||
///
|
||||
/// ```
|
||||
@ -264,8 +261,6 @@ impl<K, V, S> HashMap<K, V, S> {
|
||||
/// let mut map = HashMap::with_hasher(s);
|
||||
/// map.insert(1, 2);
|
||||
/// ```
|
||||
///
|
||||
/// [`BuildHasher`]: ../../std/hash/trait.BuildHasher.html
|
||||
#[inline]
|
||||
#[stable(feature = "hashmap_build_hasher", since = "1.7.0")]
|
||||
pub fn with_hasher(hash_builder: S) -> HashMap<K, V, S> {
|
||||
@ -296,8 +291,6 @@ pub fn with_hasher(hash_builder: S) -> HashMap<K, V, S> {
|
||||
/// let mut map = HashMap::with_capacity_and_hasher(10, s);
|
||||
/// map.insert(1, 2);
|
||||
/// ```
|
||||
///
|
||||
/// [`BuildHasher`]: ../../std/hash/trait.BuildHasher.html
|
||||
#[inline]
|
||||
#[stable(feature = "hashmap_build_hasher", since = "1.7.0")]
|
||||
pub fn with_capacity_and_hasher(capacity: usize, hash_builder: S) -> HashMap<K, V, S> {
|
||||
@ -524,8 +517,6 @@ pub fn clear(&mut self) {
|
||||
|
||||
/// Returns a reference to the map's [`BuildHasher`].
|
||||
///
|
||||
/// [`BuildHasher`]: ../../std/hash/trait.BuildHasher.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
@ -556,8 +547,6 @@ impl<K, V, S> HashMap<K, V, S>
|
||||
///
|
||||
/// Panics if the new allocation size overflows [`usize`].
|
||||
///
|
||||
/// [`usize`]: ../../std/primitive.usize.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
@ -676,9 +665,6 @@ pub fn entry(&mut self, key: K) -> Entry<'_, K, V> {
|
||||
/// [`Hash`] and [`Eq`] on the borrowed form *must* match those for
|
||||
/// the key type.
|
||||
///
|
||||
/// [`Eq`]: ../../std/cmp/trait.Eq.html
|
||||
/// [`Hash`]: ../../std/hash/trait.Hash.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
@ -705,9 +691,6 @@ pub fn get<Q: ?Sized>(&self, k: &Q) -> Option<&V>
|
||||
/// [`Hash`] and [`Eq`] on the borrowed form *must* match those for
|
||||
/// the key type.
|
||||
///
|
||||
/// [`Eq`]: ../../std/cmp/trait.Eq.html
|
||||
/// [`Hash`]: ../../std/hash/trait.Hash.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
@ -734,9 +717,6 @@ pub fn get_key_value<Q: ?Sized>(&self, k: &Q) -> Option<(&K, &V)>
|
||||
/// [`Hash`] and [`Eq`] on the borrowed form *must* match those for
|
||||
/// the key type.
|
||||
///
|
||||
/// [`Eq`]: ../../std/cmp/trait.Eq.html
|
||||
/// [`Hash`]: ../../std/hash/trait.Hash.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
@ -763,9 +743,6 @@ pub fn contains_key<Q: ?Sized>(&self, k: &Q) -> bool
|
||||
/// [`Hash`] and [`Eq`] on the borrowed form *must* match those for
|
||||
/// the key type.
|
||||
///
|
||||
/// [`Eq`]: ../../std/cmp/trait.Eq.html
|
||||
/// [`Hash`]: ../../std/hash/trait.Hash.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
@ -797,8 +774,7 @@ pub fn get_mut<Q: ?Sized>(&mut self, k: &Q) -> Option<&mut V>
|
||||
/// types that can be `==` without being identical. See the [module-level
|
||||
/// documentation] for more.
|
||||
///
|
||||
/// [`None`]: ../../std/option/enum.Option.html#variant.None
|
||||
/// [module-level documentation]: index.html#insert-and-complex-keys
|
||||
/// [module-level documentation]: crate::collections#insert-and-complex-keys
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
@ -826,9 +802,6 @@ pub fn insert(&mut self, k: K, v: V) -> Option<V> {
|
||||
/// [`Hash`] and [`Eq`] on the borrowed form *must* match those for
|
||||
/// the key type.
|
||||
///
|
||||
/// [`Eq`]: ../../std/cmp/trait.Eq.html
|
||||
/// [`Hash`]: ../../std/hash/trait.Hash.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
@ -856,9 +829,6 @@ pub fn remove<Q: ?Sized>(&mut self, k: &Q) -> Option<V>
|
||||
/// [`Hash`] and [`Eq`] on the borrowed form *must* match those for
|
||||
/// the key type.
|
||||
///
|
||||
/// [`Eq`]: ../../std/cmp/trait.Eq.html
|
||||
/// [`Hash`]: ../../std/hash/trait.Hash.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
@ -1040,8 +1010,7 @@ fn index(&self, key: &Q) -> &V {
|
||||
/// This `struct` is created by the [`iter`] method on [`HashMap`]. See its
|
||||
/// documentation for more.
|
||||
///
|
||||
/// [`iter`]: struct.HashMap.html#method.iter
|
||||
/// [`HashMap`]: struct.HashMap.html
|
||||
/// [`iter`]: HashMap::iter
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct Iter<'a, K: 'a, V: 'a> {
|
||||
base: base::Iter<'a, K, V>,
|
||||
@ -1068,8 +1037,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
/// This `struct` is created by the [`iter_mut`] method on [`HashMap`]. See its
|
||||
/// documentation for more.
|
||||
///
|
||||
/// [`iter_mut`]: struct.HashMap.html#method.iter_mut
|
||||
/// [`HashMap`]: struct.HashMap.html
|
||||
/// [`iter_mut`]: HashMap::iter_mut
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct IterMut<'a, K: 'a, V: 'a> {
|
||||
base: base::IterMut<'a, K, V>,
|
||||
@ -1088,8 +1056,7 @@ pub(super) fn iter(&self) -> Iter<'_, K, V> {
|
||||
/// This `struct` is created by the [`into_iter`] method on [`HashMap`]
|
||||
/// (provided by the `IntoIterator` trait). See its documentation for more.
|
||||
///
|
||||
/// [`into_iter`]: struct.HashMap.html#method.into_iter
|
||||
/// [`HashMap`]: struct.HashMap.html
|
||||
/// [`into_iter`]: IntoIterator::into_iter
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct IntoIter<K, V> {
|
||||
base: base::IntoIter<K, V>,
|
||||
@ -1108,8 +1075,7 @@ pub(super) fn iter(&self) -> Iter<'_, K, V> {
|
||||
/// This `struct` is created by the [`keys`] method on [`HashMap`]. See its
|
||||
/// documentation for more.
|
||||
///
|
||||
/// [`keys`]: struct.HashMap.html#method.keys
|
||||
/// [`HashMap`]: struct.HashMap.html
|
||||
/// [`keys`]: HashMap::keys
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct Keys<'a, K: 'a, V: 'a> {
|
||||
inner: Iter<'a, K, V>,
|
||||
@ -1136,8 +1102,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
/// This `struct` is created by the [`values`] method on [`HashMap`]. See its
|
||||
/// documentation for more.
|
||||
///
|
||||
/// [`values`]: struct.HashMap.html#method.values
|
||||
/// [`HashMap`]: struct.HashMap.html
|
||||
/// [`values`]: HashMap::values
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct Values<'a, K: 'a, V: 'a> {
|
||||
inner: Iter<'a, K, V>,
|
||||
@ -1164,8 +1129,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
/// This `struct` is created by the [`drain`] method on [`HashMap`]. See its
|
||||
/// documentation for more.
|
||||
///
|
||||
/// [`drain`]: struct.HashMap.html#method.drain
|
||||
/// [`HashMap`]: struct.HashMap.html
|
||||
/// [`drain`]: HashMap::drain
|
||||
#[stable(feature = "drain", since = "1.6.0")]
|
||||
pub struct Drain<'a, K: 'a, V: 'a> {
|
||||
base: base::Drain<'a, K, V>,
|
||||
@ -1184,8 +1148,7 @@ pub(super) fn iter(&self) -> Iter<'_, K, V> {
|
||||
/// This `struct` is created by the [`values_mut`] method on [`HashMap`]. See its
|
||||
/// documentation for more.
|
||||
///
|
||||
/// [`values_mut`]: struct.HashMap.html#method.values_mut
|
||||
/// [`HashMap`]: struct.HashMap.html
|
||||
/// [`values_mut`]: HashMap::values_mut
|
||||
#[stable(feature = "map_values_mut", since = "1.10.0")]
|
||||
pub struct ValuesMut<'a, K: 'a, V: 'a> {
|
||||
inner: IterMut<'a, K, V>,
|
||||
@ -1195,7 +1158,7 @@ pub struct ValuesMut<'a, K: 'a, V: 'a> {
|
||||
///
|
||||
/// See the [`HashMap::raw_entry_mut`] docs for usage examples.
|
||||
///
|
||||
/// [`HashMap::raw_entry_mut`]: struct.HashMap.html#method.raw_entry_mut
|
||||
/// [`HashMap::raw_entry_mut`]: HashMap::raw_entry_mut
|
||||
|
||||
#[unstable(feature = "hash_raw_entry", issue = "56167")]
|
||||
pub struct RawEntryBuilderMut<'a, K: 'a, V: 'a, S: 'a> {
|
||||
@ -1209,9 +1172,8 @@ pub struct RawEntryBuilderMut<'a, K: 'a, V: 'a, S: 'a> {
|
||||
/// This `enum` is constructed through the [`raw_entry_mut`] method on [`HashMap`],
|
||||
/// then calling one of the methods of that [`RawEntryBuilderMut`].
|
||||
///
|
||||
/// [`HashMap`]: struct.HashMap.html
|
||||
/// [`Entry`]: enum.Entry.html
|
||||
/// [`raw_entry_mut`]: struct.HashMap.html#method.raw_entry_mut
|
||||
/// [`raw_entry_mut`]: HashMap::raw_entry_mut
|
||||
/// [`RawEntryBuilderMut`]: struct.RawEntryBuilderMut.html
|
||||
#[unstable(feature = "hash_raw_entry", issue = "56167")]
|
||||
pub enum RawEntryMut<'a, K: 'a, V: 'a, S: 'a> {
|
||||
@ -1223,8 +1185,6 @@ pub enum RawEntryMut<'a, K: 'a, V: 'a, S: 'a> {
|
||||
|
||||
/// A view into an occupied entry in a `HashMap`.
|
||||
/// It is part of the [`RawEntryMut`] enum.
|
||||
///
|
||||
/// [`RawEntryMut`]: enum.RawEntryMut.html
|
||||
#[unstable(feature = "hash_raw_entry", issue = "56167")]
|
||||
pub struct RawOccupiedEntryMut<'a, K: 'a, V: 'a> {
|
||||
base: base::RawOccupiedEntryMut<'a, K, V>,
|
||||
@ -1232,8 +1192,6 @@ pub struct RawOccupiedEntryMut<'a, K: 'a, V: 'a> {
|
||||
|
||||
/// A view into a vacant entry in a `HashMap`.
|
||||
/// It is part of the [`RawEntryMut`] enum.
|
||||
///
|
||||
/// [`RawEntryMut`]: enum.RawEntryMut.html
|
||||
#[unstable(feature = "hash_raw_entry", issue = "56167")]
|
||||
pub struct RawVacantEntryMut<'a, K: 'a, V: 'a, S: 'a> {
|
||||
base: base::RawVacantEntryMut<'a, K, V, S>,
|
||||
@ -1243,7 +1201,7 @@ pub struct RawVacantEntryMut<'a, K: 'a, V: 'a, S: 'a> {
|
||||
///
|
||||
/// See the [`HashMap::raw_entry`] docs for usage examples.
|
||||
///
|
||||
/// [`HashMap::raw_entry`]: struct.HashMap.html#method.raw_entry
|
||||
/// [`HashMap::raw_entry`]: HashMap::raw_entry
|
||||
#[unstable(feature = "hash_raw_entry", issue = "56167")]
|
||||
pub struct RawEntryBuilder<'a, K: 'a, V: 'a, S: 'a> {
|
||||
map: &'a HashMap<K, V, S>,
|
||||
@ -1597,8 +1555,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
///
|
||||
/// This `enum` is constructed from the [`entry`] method on [`HashMap`].
|
||||
///
|
||||
/// [`HashMap`]: struct.HashMap.html
|
||||
/// [`entry`]: struct.HashMap.html#method.entry
|
||||
/// [`entry`]: HashMap::entry
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub enum Entry<'a, K: 'a, V: 'a> {
|
||||
/// An occupied entry.
|
||||
@ -2156,7 +2113,7 @@ pub fn get(&self) -> &V {
|
||||
/// If you need a reference to the `OccupiedEntry` which may outlive the
|
||||
/// destruction of the `Entry` value, see [`into_mut`].
|
||||
///
|
||||
/// [`into_mut`]: #method.into_mut
|
||||
/// [`into_mut`]: Self::into_mut
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
@ -2189,7 +2146,7 @@ pub fn get_mut(&mut self) -> &mut V {
|
||||
///
|
||||
/// If you need multiple references to the `OccupiedEntry`, see [`get_mut`].
|
||||
///
|
||||
/// [`get_mut`]: #method.get_mut
|
||||
/// [`get_mut`]: Self::get_mut
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
@ -2475,9 +2432,6 @@ fn extend_reserve(&mut self, additional: usize) {
|
||||
/// [`Hasher`], but the hashers created by two different `RandomState`
|
||||
/// instances are unlikely to produce the same result for the same values.
|
||||
///
|
||||
/// [`HashMap`]: struct.HashMap.html
|
||||
/// [`Hasher`]: ../../hash/trait.Hasher.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
@ -2547,9 +2501,6 @@ fn build_hasher(&self) -> DefaultHasher {
|
||||
///
|
||||
/// The internal algorithm is not specified, and so it and its hashes should
|
||||
/// not be relied upon over releases.
|
||||
///
|
||||
/// [`RandomState`]: struct.RandomState.html
|
||||
/// [`Hasher`]: ../../hash/trait.Hasher.html
|
||||
#[stable(feature = "hashmap_default_hasher", since = "1.13.0")]
|
||||
#[allow(deprecated)]
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -98,12 +98,8 @@
|
||||
/// // use the values stored in the set
|
||||
/// ```
|
||||
///
|
||||
/// [`Cell`]: ../../std/cell/struct.Cell.html
|
||||
/// [`Eq`]: ../../std/cmp/trait.Eq.html
|
||||
/// [`Hash`]: ../../std/hash/trait.Hash.html
|
||||
/// [`HashMap`]: struct.HashMap.html
|
||||
/// [`PartialEq`]: ../../std/cmp/trait.PartialEq.html
|
||||
/// [`RefCell`]: ../../std/cell/struct.RefCell.html
|
||||
/// [`RefCell`]: crate::cell::RefCell
|
||||
/// [`Cell`]: crate::cell::Cell
|
||||
#[derive(Clone)]
|
||||
#[cfg_attr(not(test), rustc_diagnostic_item = "hashset_type")]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -286,8 +282,6 @@ pub fn clear(&mut self) {
|
||||
/// let mut set = HashSet::with_hasher(s);
|
||||
/// set.insert(2);
|
||||
/// ```
|
||||
///
|
||||
/// [`BuildHasher`]: ../../std/hash/trait.BuildHasher.html
|
||||
#[inline]
|
||||
#[stable(feature = "hashmap_build_hasher", since = "1.7.0")]
|
||||
pub fn with_hasher(hasher: S) -> HashSet<T, S> {
|
||||
@ -318,8 +312,6 @@ pub fn with_hasher(hasher: S) -> HashSet<T, S> {
|
||||
/// let mut set = HashSet::with_capacity_and_hasher(10, s);
|
||||
/// set.insert(1);
|
||||
/// ```
|
||||
///
|
||||
/// [`BuildHasher`]: ../../std/hash/trait.BuildHasher.html
|
||||
#[inline]
|
||||
#[stable(feature = "hashmap_build_hasher", since = "1.7.0")]
|
||||
pub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> HashSet<T, S> {
|
||||
@ -328,8 +320,6 @@ pub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> HashSet<T, S> {
|
||||
|
||||
/// Returns a reference to the set's [`BuildHasher`].
|
||||
///
|
||||
/// [`BuildHasher`]: ../../std/hash/trait.BuildHasher.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
@ -577,9 +567,6 @@ pub fn union<'a>(&'a self, other: &'a HashSet<T, S>) -> Union<'a, T, S> {
|
||||
/// assert_eq!(set.contains(&1), true);
|
||||
/// assert_eq!(set.contains(&4), false);
|
||||
/// ```
|
||||
///
|
||||
/// [`Eq`]: ../../std/cmp/trait.Eq.html
|
||||
/// [`Hash`]: ../../std/hash/trait.Hash.html
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn contains<Q: ?Sized>(&self, value: &Q) -> bool
|
||||
@ -605,9 +592,6 @@ pub fn contains<Q: ?Sized>(&self, value: &Q) -> bool
|
||||
/// assert_eq!(set.get(&2), Some(&2));
|
||||
/// assert_eq!(set.get(&4), None);
|
||||
/// ```
|
||||
///
|
||||
/// [`Eq`]: ../../std/cmp/trait.Eq.html
|
||||
/// [`Hash`]: ../../std/hash/trait.Hash.html
|
||||
#[inline]
|
||||
#[stable(feature = "set_recovery", since = "1.9.0")]
|
||||
pub fn get<Q: ?Sized>(&self, value: &Q) -> Option<&T>
|
||||
@ -849,9 +833,6 @@ pub fn replace(&mut self, value: T) -> Option<T> {
|
||||
/// assert_eq!(set.remove(&2), true);
|
||||
/// assert_eq!(set.remove(&2), false);
|
||||
/// ```
|
||||
///
|
||||
/// [`Eq`]: ../../std/cmp/trait.Eq.html
|
||||
/// [`Hash`]: ../../std/hash/trait.Hash.html
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn remove<Q: ?Sized>(&mut self, value: &Q) -> bool
|
||||
@ -877,9 +858,6 @@ pub fn remove<Q: ?Sized>(&mut self, value: &Q) -> bool
|
||||
/// assert_eq!(set.take(&2), Some(2));
|
||||
/// assert_eq!(set.take(&2), None);
|
||||
/// ```
|
||||
///
|
||||
/// [`Eq`]: ../../std/cmp/trait.Eq.html
|
||||
/// [`Hash`]: ../../std/hash/trait.Hash.html
|
||||
#[inline]
|
||||
#[stable(feature = "set_recovery", since = "1.9.0")]
|
||||
pub fn take<Q: ?Sized>(&mut self, value: &Q) -> Option<T>
|
||||
@ -1153,8 +1131,7 @@ fn sub(self, rhs: &HashSet<T, S>) -> HashSet<T, S> {
|
||||
/// This `struct` is created by the [`iter`] method on [`HashSet`].
|
||||
/// See its documentation for more.
|
||||
///
|
||||
/// [`HashSet`]: struct.HashSet.html
|
||||
/// [`iter`]: struct.HashSet.html#method.iter
|
||||
/// [`iter`]: HashSet::iter
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct Iter<'a, K: 'a> {
|
||||
iter: Keys<'a, K, ()>,
|
||||
@ -1165,8 +1142,7 @@ pub struct Iter<'a, K: 'a> {
|
||||
/// This `struct` is created by the [`into_iter`] method on [`HashSet`]
|
||||
/// (provided by the `IntoIterator` trait). See its documentation for more.
|
||||
///
|
||||
/// [`HashSet`]: struct.HashSet.html
|
||||
/// [`into_iter`]: struct.HashSet.html#method.into_iter
|
||||
/// [`into_iter`]: IntoIterator::into_iter
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct IntoIter<K> {
|
||||
iter: map::IntoIter<K, ()>,
|
||||
@ -1177,8 +1153,7 @@ pub struct IntoIter<K> {
|
||||
/// This `struct` is created by the [`drain`] method on [`HashSet`].
|
||||
/// See its documentation for more.
|
||||
///
|
||||
/// [`HashSet`]: struct.HashSet.html
|
||||
/// [`drain`]: struct.HashSet.html#method.drain
|
||||
/// [`drain`]: HashSet::drain
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct Drain<'a, K: 'a> {
|
||||
iter: map::Drain<'a, K, ()>,
|
||||
@ -1189,8 +1164,7 @@ pub struct Drain<'a, K: 'a> {
|
||||
/// This `struct` is created by the [`intersection`] method on [`HashSet`].
|
||||
/// See its documentation for more.
|
||||
///
|
||||
/// [`HashSet`]: struct.HashSet.html
|
||||
/// [`intersection`]: struct.HashSet.html#method.intersection
|
||||
/// [`intersection`]: HashSet::intersection
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct Intersection<'a, T: 'a, S: 'a> {
|
||||
// iterator of the first set
|
||||
@ -1204,8 +1178,7 @@ pub struct Intersection<'a, T: 'a, S: 'a> {
|
||||
/// This `struct` is created by the [`difference`] method on [`HashSet`].
|
||||
/// See its documentation for more.
|
||||
///
|
||||
/// [`HashSet`]: struct.HashSet.html
|
||||
/// [`difference`]: struct.HashSet.html#method.difference
|
||||
/// [`difference`]: HashSet::difference
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct Difference<'a, T: 'a, S: 'a> {
|
||||
// iterator of the first set
|
||||
@ -1219,8 +1192,7 @@ pub struct Difference<'a, T: 'a, S: 'a> {
|
||||
/// This `struct` is created by the [`symmetric_difference`] method on
|
||||
/// [`HashSet`]. See its documentation for more.
|
||||
///
|
||||
/// [`HashSet`]: struct.HashSet.html
|
||||
/// [`symmetric_difference`]: struct.HashSet.html#method.symmetric_difference
|
||||
/// [`symmetric_difference`]: HashSet::symmetric_difference
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct SymmetricDifference<'a, T: 'a, S: 'a> {
|
||||
iter: Chain<Difference<'a, T, S>, Difference<'a, T, S>>,
|
||||
@ -1231,8 +1203,7 @@ pub struct SymmetricDifference<'a, T: 'a, S: 'a> {
|
||||
/// This `struct` is created by the [`union`] method on [`HashSet`].
|
||||
/// See its documentation for more.
|
||||
///
|
||||
/// [`HashSet`]: struct.HashSet.html
|
||||
/// [`union`]: struct.HashSet.html#method.union
|
||||
/// [`union`]: HashSet::union
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct Union<'a, T: 'a, S: 'a> {
|
||||
iter: Chain<Iter<'a, T>, Difference<'a, T, S>>,
|
||||
|
@ -238,25 +238,14 @@
|
||||
//! contract. The implementation of many of these functions are subject to change over
|
||||
//! time and may call fewer or more syscalls/library functions.
|
||||
//!
|
||||
//! [`Read`]: trait.Read.html
|
||||
//! [`Write`]: trait.Write.html
|
||||
//! [`Seek`]: trait.Seek.html
|
||||
//! [`BufRead`]: trait.BufRead.html
|
||||
//! [`File`]: ../fs/struct.File.html
|
||||
//! [`TcpStream`]: ../net/struct.TcpStream.html
|
||||
//! [`Vec<T>`]: ../vec/struct.Vec.html
|
||||
//! [`BufReader`]: struct.BufReader.html
|
||||
//! [`BufWriter`]: struct.BufWriter.html
|
||||
//! [`Write::write`]: trait.Write.html#tymethod.write
|
||||
//! [`io::stdout`]: fn.stdout.html
|
||||
//! [`println!`]: ../macro.println.html
|
||||
//! [`Lines`]: struct.Lines.html
|
||||
//! [`io::Result`]: type.Result.html
|
||||
//! [`File`]: crate::fs::File
|
||||
//! [`TcpStream`]: crate::net::TcpStream
|
||||
//! [`Vec<T>`]: crate::vec::Vec
|
||||
//! [`io::stdout`]: stdout
|
||||
//! [`io::Result`]: crate::io::Result
|
||||
//! [`?` operator]: ../../book/appendix-02-operators.html
|
||||
//! [`Read::read`]: trait.Read.html#tymethod.read
|
||||
//! [`Result`]: ../result/enum.Result.html
|
||||
//! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap
|
||||
// ignore-tidy-filelength
|
||||
//! [`Result`]: crate::result::Result
|
||||
//! [`.unwrap()`]: crate::result::Result::unwrap
|
||||
|
||||
#![stable(feature = "rust1", since = "1.0.0")]
|
||||
|
||||
@ -491,12 +480,10 @@ pub(crate) fn default_write_vectored<F>(write: F, bufs: &[IoSlice<'_>]) -> Resul
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// [`read()`]: trait.Read.html#tymethod.read
|
||||
/// [`std::io`]: ../../std/io/index.html
|
||||
/// [`File`]: ../fs/struct.File.html
|
||||
/// [`BufRead`]: trait.BufRead.html
|
||||
/// [`BufReader`]: struct.BufReader.html
|
||||
/// [`&str`]: ../../std/primitive.str.html
|
||||
/// [`read()`]: Read::read
|
||||
/// [`&str`]: str
|
||||
/// [`std::io`]: self
|
||||
/// [`File`]: crate::fs::File
|
||||
/// [slice]: ../../std/primitive.slice.html
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[doc(spotlight)]
|
||||
@ -535,7 +522,7 @@ pub trait Read {
|
||||
/// before calling `read`. Calling `read` with an uninitialized `buf` (of the kind one
|
||||
/// obtains via [`MaybeUninit<T>`]) is not safe, and can lead to undefined behavior.
|
||||
///
|
||||
/// [`MaybeUninit<T>`]: ../mem/union.MaybeUninit.html
|
||||
/// [`MaybeUninit<T>`]: crate::mem::MaybeUninit
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
@ -550,10 +537,8 @@ pub trait Read {
|
||||
///
|
||||
/// [`File`]s implement `Read`:
|
||||
///
|
||||
/// [`Err`]: ../../std/result/enum.Result.html#variant.Err
|
||||
/// [`Ok(n)`]: ../../std/result/enum.Result.html#variant.Ok
|
||||
/// [`ErrorKind::Interrupted`]: ../../std/io/enum.ErrorKind.html#variant.Interrupted
|
||||
/// [`File`]: ../fs/struct.File.html
|
||||
/// [`Ok(n)`]: Ok
|
||||
/// [`File`]: crate::fs::File
|
||||
///
|
||||
/// ```no_run
|
||||
/// use std::io;
|
||||
@ -620,9 +605,6 @@ fn is_read_vectored(&self) -> bool {
|
||||
/// This method is unsafe because a `Read`er could otherwise return a
|
||||
/// non-zeroing `Initializer` from another `Read` type without an `unsafe`
|
||||
/// block.
|
||||
///
|
||||
/// [`Initializer::nop()`]: ../../std/io/struct.Initializer.html#method.nop
|
||||
/// [`Initializer`]: ../../std/io/struct.Initializer.html
|
||||
#[unstable(feature = "read_initializer", issue = "42788")]
|
||||
#[inline]
|
||||
unsafe fn initializer(&self) -> Initializer {
|
||||
@ -652,10 +634,9 @@ unsafe fn initializer(&self) -> Initializer {
|
||||
///
|
||||
/// [`File`]s implement `Read`:
|
||||
///
|
||||
/// [`read()`]: trait.Read.html#tymethod.read
|
||||
/// [`Ok(0)`]: ../../std/result/enum.Result.html#variant.Ok
|
||||
/// [`ErrorKind::Interrupted`]: ../../std/io/enum.ErrorKind.html#variant.Interrupted
|
||||
/// [`File`]: ../fs/struct.File.html
|
||||
/// [`read()`]: Read::read
|
||||
/// [`Ok(0)`]: Ok
|
||||
/// [`File`]: crate::fs::File
|
||||
///
|
||||
/// ```no_run
|
||||
/// use std::io;
|
||||
@ -675,7 +656,7 @@ unsafe fn initializer(&self) -> Initializer {
|
||||
/// (See also the [`std::fs::read`] convenience function for reading from a
|
||||
/// file.)
|
||||
///
|
||||
/// [`std::fs::read`]: ../fs/fn.read.html
|
||||
/// [`std::fs::read`]: crate::fs::read
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize> {
|
||||
read_to_end(self, buf)
|
||||
@ -693,13 +674,13 @@ fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize> {
|
||||
///
|
||||
/// See [`read_to_end`][readtoend] for other error semantics.
|
||||
///
|
||||
/// [readtoend]: #method.read_to_end
|
||||
/// [readtoend]: Self::read_to_end
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// [`File`][file]s implement `Read`:
|
||||
///
|
||||
/// [file]: ../fs/struct.File.html
|
||||
/// [file]: crate::fs::File
|
||||
///
|
||||
/// ```no_run
|
||||
/// use std::io;
|
||||
@ -718,7 +699,7 @@ fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize> {
|
||||
/// (See also the [`std::fs::read_to_string`] convenience function for
|
||||
/// reading from a file.)
|
||||
///
|
||||
/// [`std::fs::read_to_string`]: ../fs/fn.read_to_string.html
|
||||
/// [`std::fs::read_to_string`]: crate::fs::read_to_string
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn read_to_string(&mut self, buf: &mut String) -> Result<usize> {
|
||||
// Note that we do *not* call `.read_to_end()` here. We are passing
|
||||
@ -764,9 +745,7 @@ fn read_to_string(&mut self, buf: &mut String) -> Result<usize> {
|
||||
///
|
||||
/// [`File`]s implement `Read`:
|
||||
///
|
||||
/// [`File`]: ../fs/struct.File.html
|
||||
/// [`ErrorKind::Interrupted`]: ../../std/io/enum.ErrorKind.html#variant.Interrupted
|
||||
/// [`ErrorKind::UnexpectedEof`]: ../../std/io/enum.ErrorKind.html#variant.UnexpectedEof
|
||||
/// [`File`]: crate::fs::File
|
||||
///
|
||||
/// ```no_run
|
||||
/// use std::io;
|
||||
@ -811,7 +790,7 @@ fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> {
|
||||
///
|
||||
/// [`File`][file]s implement `Read`:
|
||||
///
|
||||
/// [file]: ../fs/struct.File.html
|
||||
/// [file]: crate::fs::File
|
||||
///
|
||||
/// ```no_run
|
||||
/// use std::io;
|
||||
@ -855,14 +834,10 @@ fn by_ref(&mut self) -> &mut Self
|
||||
///
|
||||
/// [`File`][file]s implement `Read`:
|
||||
///
|
||||
/// [file]: ../fs/struct.File.html
|
||||
/// [`Iterator`]: ../../std/iter/trait.Iterator.html
|
||||
/// [`Result`]: ../../std/result/enum.Result.html
|
||||
/// [`io::Error`]: ../../std/io/struct.Error.html
|
||||
/// [`u8`]: ../../std/primitive.u8.html
|
||||
/// [`Ok`]: ../../std/result/enum.Result.html#variant.Ok
|
||||
/// [`Err`]: ../../std/result/enum.Result.html#variant.Err
|
||||
/// [`None`]: ../../std/option/enum.Option.html#variant.None
|
||||
/// [file]: crate::fs::File
|
||||
/// [`Iterator`]: crate::iter::Iterator
|
||||
/// [`Result`]: crate::result::Result
|
||||
/// [`io::Error`]: self::Error
|
||||
///
|
||||
/// ```no_run
|
||||
/// use std::io;
|
||||
@ -896,7 +871,7 @@ fn bytes(self) -> Bytes<Self>
|
||||
///
|
||||
/// [`File`][file]s implement `Read`:
|
||||
///
|
||||
/// [file]: ../fs/struct.File.html
|
||||
/// [file]: crate::fs::File
|
||||
///
|
||||
/// ```no_run
|
||||
/// use std::io;
|
||||
@ -935,9 +910,9 @@ fn chain<R: Read>(self, next: R) -> Chain<Self, R>
|
||||
///
|
||||
/// [`File`]s implement `Read`:
|
||||
///
|
||||
/// [`File`]: ../fs/struct.File.html
|
||||
/// [`Ok(0)`]: ../../std/result/enum.Result.html#variant.Ok
|
||||
/// [`read()`]: trait.Read.html#tymethod.read
|
||||
/// [`File`]: crate::fs::File
|
||||
/// [`Ok(0)`]: Ok
|
||||
/// [`read()`]: Read::read
|
||||
///
|
||||
/// ```no_run
|
||||
/// use std::io;
|
||||
@ -1233,8 +1208,8 @@ pub fn initialize(&self, buf: &mut [u8]) {
|
||||
/// throughout [`std::io`] take and provide types which implement the `Write`
|
||||
/// trait.
|
||||
///
|
||||
/// [`write`]: #tymethod.write
|
||||
/// [`flush`]: #tymethod.flush
|
||||
/// [`write`]: Self::write
|
||||
/// [`flush`]: Self::flush
|
||||
/// [`std::io`]: index.html
|
||||
///
|
||||
/// # Examples
|
||||
@ -1260,7 +1235,7 @@ pub fn initialize(&self, buf: &mut [u8]) {
|
||||
/// The trait also provides convenience methods like [`write_all`], which calls
|
||||
/// `write` in a loop until its entire input has been written.
|
||||
///
|
||||
/// [`write_all`]: #method.write_all
|
||||
/// [`write_all`]: Self::write_all
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[doc(spotlight)]
|
||||
pub trait Write {
|
||||
@ -1292,10 +1267,6 @@ pub trait Write {
|
||||
/// An error of the [`ErrorKind::Interrupted`] kind is non-fatal and the
|
||||
/// write operation should be retried if there is nothing else to do.
|
||||
///
|
||||
/// [`Err`]: ../../std/result/enum.Result.html#variant.Err
|
||||
/// [`Ok(n)`]: ../../std/result/enum.Result.html#variant.Ok
|
||||
/// [`ErrorKind::Interrupted`]: ../../std/io/enum.ErrorKind.html#variant.Interrupted
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```no_run
|
||||
@ -1381,8 +1352,7 @@ fn is_write_vectored(&self) -> bool {
|
||||
/// This function will return the first error of
|
||||
/// non-[`ErrorKind::Interrupted`] kind that [`write`] returns.
|
||||
///
|
||||
/// [`ErrorKind::Interrupted`]: ../../std/io/enum.ErrorKind.html#variant.Interrupted
|
||||
/// [`write`]: #tymethod.write
|
||||
/// [`write`]: Self::write
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
@ -1423,8 +1393,7 @@ fn write_all(&mut self, mut buf: &[u8]) -> Result<()> {
|
||||
///
|
||||
/// If the buffer contains no data, this will never call [`write_vectored`].
|
||||
///
|
||||
/// [`write_vectored`]: #method.write_vectored
|
||||
/// [`ErrorKind::Interrupted`]: ../../std/io/enum.ErrorKind.html#variant.Interrupted
|
||||
/// [`write_vectored`]: Self::write_vectored
|
||||
///
|
||||
/// # Notes
|
||||
///
|
||||
@ -1480,19 +1449,16 @@ fn write_all_vectored(&mut self, mut bufs: &mut [IoSlice<'_>]) -> Result<()> {
|
||||
/// encountered.
|
||||
///
|
||||
/// This method is primarily used to interface with the
|
||||
/// [`format_args!`][formatargs] macro, but it is rare that this should
|
||||
/// explicitly be called. The [`write!`][write] macro should be favored to
|
||||
/// [`format_args!()`] macro, but it is rare that this should
|
||||
/// explicitly be called. The [`write!()`] macro should be favored to
|
||||
/// invoke this method instead.
|
||||
///
|
||||
/// [formatargs]: ../macro.format_args.html
|
||||
/// [write]: ../macro.write.html
|
||||
///
|
||||
/// This function internally uses the [`write_all`][writeall] method on
|
||||
/// this trait and hence will continuously write data so long as no errors
|
||||
/// are received. This also means that partial writes are not indicated in
|
||||
/// this signature.
|
||||
///
|
||||
/// [writeall]: #method.write_all
|
||||
/// [writeall]: Self::write_all
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
@ -1589,7 +1555,7 @@ fn by_ref(&mut self) -> &mut Self
|
||||
///
|
||||
/// [`File`][file]s implement `Seek`:
|
||||
///
|
||||
/// [file]: ../fs/struct.File.html
|
||||
/// [file]: crate::fs::File
|
||||
///
|
||||
/// ```no_run
|
||||
/// use std::io;
|
||||
@ -1789,9 +1755,9 @@ fn read_until<R: BufRead + ?Sized>(r: &mut R, delim: u8, buf: &mut Vec<u8>) -> R
|
||||
/// [`BufReader`] to the rescue!
|
||||
///
|
||||
/// [`BufReader`]: struct.BufReader.html
|
||||
/// [`File`]: ../fs/struct.File.html
|
||||
/// [`read_line`]: #method.read_line
|
||||
/// [`lines`]: #method.lines
|
||||
/// [`File`]: crate::fs::File
|
||||
/// [`read_line`]: Self::read_line
|
||||
/// [`lines`]: Self::lines
|
||||
/// [`Read`]: trait.Read.html
|
||||
///
|
||||
/// ```no_run
|
||||
@ -1823,7 +1789,7 @@ pub trait BufRead: Read {
|
||||
/// be called with the number of bytes that are consumed from this buffer to
|
||||
/// ensure that the bytes are never returned twice.
|
||||
///
|
||||
/// [`consume`]: #tymethod.consume
|
||||
/// [`consume`]: Self::consume
|
||||
///
|
||||
/// An empty buffer returned indicates that the stream has reached EOF.
|
||||
///
|
||||
@ -1873,7 +1839,7 @@ pub trait BufRead: Read {
|
||||
/// Since `consume()` is meant to be used with [`fill_buf`],
|
||||
/// that method's example includes an example of `consume()`.
|
||||
///
|
||||
/// [`fill_buf`]: #tymethod.fill_buf
|
||||
/// [`fill_buf`]: Self::fill_buf
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn consume(&mut self, amt: usize);
|
||||
|
||||
@ -1897,7 +1863,7 @@ pub trait BufRead: Read {
|
||||
/// If an I/O error is encountered then all bytes read so far will be
|
||||
/// present in `buf` and its length will have been adjusted appropriately.
|
||||
///
|
||||
/// [`fill_buf`]: #tymethod.fill_buf
|
||||
/// [`fill_buf`]: Self::fill_buf
|
||||
/// [`ErrorKind::Interrupted`]: enum.ErrorKind.html#variant.Interrupted
|
||||
///
|
||||
/// # Examples
|
||||
@ -1962,7 +1928,7 @@ fn read_until(&mut self, byte: u8, buf: &mut Vec<u8>) -> Result<usize> {
|
||||
/// error is encountered then `buf` may contain some bytes already read in
|
||||
/// the event that all data read so far was valid UTF-8.
|
||||
///
|
||||
/// [`read_until`]: #method.read_until
|
||||
/// [`read_until`]: Self::read_until
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
@ -2015,9 +1981,9 @@ fn read_line(&mut self, buf: &mut String) -> Result<usize> {
|
||||
/// This function will yield errors whenever [`read_until`] would have
|
||||
/// also yielded an error.
|
||||
///
|
||||
/// [`io::Result`]: type.Result.html
|
||||
/// [`Vec<u8>`]: ../vec/struct.Vec.html
|
||||
/// [`read_until`]: #method.read_until
|
||||
/// [`io::Result`]: self::Result
|
||||
/// [`Vec<u8>`]: crate::vec::Vec
|
||||
/// [`read_until`]: Self::read_until
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
@ -2052,8 +2018,7 @@ fn split(self, byte: u8) -> Split<Self>
|
||||
/// [`io::Result`]`<`[`String`]`>`. Each string returned will *not* have a newline
|
||||
/// byte (the 0xA byte) or CRLF (0xD, 0xA bytes) at the end.
|
||||
///
|
||||
/// [`io::Result`]: type.Result.html
|
||||
/// [`String`]: ../string/struct.String.html
|
||||
/// [`io::Result`]: self::Result
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
@ -2061,8 +2026,6 @@ fn split(self, byte: u8) -> Split<Self>
|
||||
/// this example, we use [`Cursor`] to iterate over all the lines in a byte
|
||||
/// slice.
|
||||
///
|
||||
/// [`Cursor`]: struct.Cursor.html
|
||||
///
|
||||
/// ```
|
||||
/// use std::io::{self, BufRead};
|
||||
///
|
||||
@ -2253,8 +2216,6 @@ impl<T> Take<T> {
|
||||
/// This instance may reach `EOF` after reading fewer bytes than indicated by
|
||||
/// this method if the underlying [`Read`] instance reaches EOF.
|
||||
///
|
||||
/// [`Read`]: ../../std/io/trait.Read.html
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```no_run
|
||||
|
@ -23,6 +23,32 @@
|
||||
|
||||
use crate::Redirect::*;
|
||||
|
||||
// Add linkcheck exceptions here
|
||||
// If at all possible you should use intra-doc links to avoid linkcheck issues. These
|
||||
// are cases where that does not work
|
||||
// [(generated_documentation_page, &[broken_links])]
|
||||
const LINKCHECK_EXCEPTIONS: &[(&str, &[&str])] = &[
|
||||
// These are methods on slice, and `Self` does not work on primitive impls
|
||||
// in intra-doc links (primitive impls are weird)
|
||||
// https://github.com/rust-lang/rust/issues/62834 is necessary to be
|
||||
// able to link to slices
|
||||
(
|
||||
"std/io/struct.IoSlice.html",
|
||||
&[
|
||||
"#method.as_mut_ptr",
|
||||
"#method.sort_by_key",
|
||||
"#method.make_ascii_uppercase",
|
||||
"#method.make_ascii_lowercase",
|
||||
],
|
||||
),
|
||||
// These try to link to std::collections, but are defined in alloc
|
||||
// https://github.com/rust-lang/rust/issues/74481
|
||||
("std/collections/btree_map/struct.BTreeMap.html", &["#insert-and-complex-keys"]),
|
||||
("std/collections/btree_set/struct.BTreeSet.html", &["#insert-and-complex-keys"]),
|
||||
("alloc/collections/btree_map/struct.BTreeMap.html", &["#insert-and-complex-keys"]),
|
||||
("alloc/collections/btree_set/struct.BTreeSet.html", &["#insert-and-complex-keys"]),
|
||||
];
|
||||
|
||||
macro_rules! t {
|
||||
($e:expr) => {
|
||||
match $e {
|
||||
@ -111,35 +137,20 @@ fn walk(cache: &mut Cache, root: &Path, dir: &Path, errors: &mut bool) {
|
||||
}
|
||||
}
|
||||
|
||||
fn is_exception(file: &Path, link: &str) -> bool {
|
||||
if let Some(entry) = LINKCHECK_EXCEPTIONS.iter().find(|&(f, _)| file.ends_with(f)) {
|
||||
entry.1.contains(&link)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
fn check(cache: &mut Cache, root: &Path, file: &Path, errors: &mut bool) -> Option<PathBuf> {
|
||||
// Ignore non-HTML files.
|
||||
if file.extension().and_then(|s| s.to_str()) != Some("html") {
|
||||
return None;
|
||||
}
|
||||
|
||||
// Unfortunately we're not 100% full of valid links today to we need a few
|
||||
// exceptions to get this past `make check` today.
|
||||
// FIXME(#32129)
|
||||
if file.ends_with("std/io/struct.IoSlice.html")
|
||||
|| file.ends_with("std/string/struct.String.html")
|
||||
{
|
||||
return None;
|
||||
}
|
||||
// FIXME(#32553)
|
||||
if file.ends_with("alloc/string/struct.String.html") {
|
||||
return None;
|
||||
}
|
||||
// FIXME(#32130)
|
||||
if file.ends_with("alloc/collections/btree_map/struct.BTreeMap.html")
|
||||
|| file.ends_with("alloc/collections/btree_set/struct.BTreeSet.html")
|
||||
|| file.ends_with("std/collections/btree_map/struct.BTreeMap.html")
|
||||
|| file.ends_with("std/collections/btree_set/struct.BTreeSet.html")
|
||||
|| file.ends_with("std/collections/hash_map/struct.HashMap.html")
|
||||
|| file.ends_with("std/collections/hash_set/struct.HashSet.html")
|
||||
{
|
||||
return None;
|
||||
}
|
||||
|
||||
let res = load_file(cache, root, file, SkipRedirect);
|
||||
let (pretty_file, contents) = match res {
|
||||
Ok(res) => res,
|
||||
@ -254,17 +265,20 @@ fn check(cache: &mut Cache, root: &Path, file: &Path, errors: &mut bool) -> Opti
|
||||
let entry = &mut cache.get_mut(&pretty_path).unwrap();
|
||||
entry.parse_ids(&pretty_path, &contents, errors);
|
||||
|
||||
if !entry.ids.contains(*fragment) {
|
||||
if !entry.ids.contains(*fragment) && !is_exception(file, &format!("#{}", fragment))
|
||||
{
|
||||
*errors = true;
|
||||
print!("{}:{}: broken link fragment ", pretty_file.display(), i + 1);
|
||||
println!("`#{}` pointing to `{}`", fragment, pretty_path.display());
|
||||
};
|
||||
}
|
||||
} else {
|
||||
*errors = true;
|
||||
print!("{}:{}: broken link - ", pretty_file.display(), i + 1);
|
||||
let pretty_path = path.strip_prefix(root).unwrap_or(&path);
|
||||
println!("{}", pretty_path.display());
|
||||
if !is_exception(file, pretty_path.to_str().unwrap()) {
|
||||
*errors = true;
|
||||
print!("{}:{}: broken link - ", pretty_file.display(), i + 1);
|
||||
println!("{}", pretty_path.display());
|
||||
}
|
||||
}
|
||||
});
|
||||
Some(pretty_file)
|
||||
|
Loading…
Reference in New Issue
Block a user