@@ -195,7 +195,7 @@ mod break_keyword {}
195195/// to be most things that would be reasonable to have in a constant (barring `const fn`s). For
196196/// example, you can't have a [`File`] as a `const`.
197197///
198- /// [`File`]: crate::fs:: File
198+ /// [`File`]: ../std/fs/struct. File.html
199199///
200200/// The only lifetime allowed in a constant is `'static`, which is the lifetime that encompasses
201201/// all others in a Rust program. For example, if you wanted to define a constant string, it would
@@ -484,7 +484,7 @@ mod extern_keyword {}
484484
485485#[ doc( keyword = "false" ) ]
486486//
487- /// A value of type [`bool`] representing logical **false**.
487+ /// A value of type [`prim@ bool`] representing logical **false**.
488488///
489489/// `false` is the logical opposite of [`true`].
490490///
@@ -1235,31 +1235,18 @@ mod ref_keyword {}
12351235/// `return` returns from the function immediately (an "early return"):
12361236///
12371237/// ```no_run
1238- /// use std::fs::File;
1239- /// use std::io::{Error, ErrorKind, Read, Result} ;
1238+ /// fn main() -> Result<(), &'static str> {
1239+ /// let contents = "Hello, world!" ;
12401240///
1241- /// fn main() -> Result<()> {
1242- /// let mut file = match File::open("foo.txt") {
1243- /// Ok(f) => f,
1244- /// Err(e) => return Err(e),
1245- /// };
1246- ///
1247- /// let mut contents = String::new();
1248- /// let size = match file.read_to_string(&mut contents) {
1249- /// Ok(s) => s,
1250- /// Err(e) => return Err(e),
1251- /// };
1241+ /// if contents.contains("impossible!") {
1242+ /// return Err("oh no!");
1243+ /// }
12521244///
1253- /// if contents.contains("impossible!") {
1254- /// return Err(Error::new(ErrorKind::Other, "oh no!"));
1255- /// }
1256- ///
1257- /// if size > 9000 {
1258- /// return Err(Error::new(ErrorKind::Other, "over 9000!"));
1259- /// }
1245+ /// if contents.len() > 9000 {
1246+ /// return Err("over 9000!");
1247+ /// }
12601248///
1261- /// assert_eq!(contents, "Hello, world!");
1262- /// Ok(())
1249+ /// Ok(())
12631250/// }
12641251/// ```
12651252///
@@ -1631,8 +1618,8 @@ mod self_upper_keyword {}
16311618/// [`extern`]: keyword.extern.html
16321619/// [`mut`]: keyword.mut.html
16331620/// [`unsafe`]: keyword.unsafe.html
1634- /// [`Mutex`]: sync:: Mutex
1635- /// [`OnceLock`]: sync:: OnceLock
1621+ /// [`Mutex`]: ../std/ sync/struct. Mutex.html
1622+ /// [`OnceLock`]: ../std/ sync/struct. OnceLock.html
16361623/// [`RefCell`]: cell::RefCell
16371624/// [atomic]: sync::atomic
16381625/// [Reference]: ../reference/items/static-items.html
@@ -1959,7 +1946,7 @@ mod trait_keyword {}
19591946
19601947#[ doc( keyword = "true" ) ]
19611948//
1962- /// A value of type [`bool`] representing logical **true**.
1949+ /// A value of type [`prim@ bool`] representing logical **true**.
19631950///
19641951/// Logically `true` is not equal to [`false`].
19651952///
@@ -2146,22 +2133,30 @@ mod type_keyword {}
21462133/// Since `unsafe fn` and `unsafe trait` indicate that there is a safety
21472134/// contract that the compiler cannot enforce, documenting it is important. The
21482135/// standard library has many examples of this, like the following which is an
2149- /// extract from [`Vec::set_len `]. The `# Safety` section explains the contract
2136+ /// extract from [`ptr::replace `]. The `# Safety` section explains the contract
21502137/// that must be fulfilled to safely call the function.
21512138///
21522139/// ```rust,ignore (stub-to-show-doc-example)
2153- /// /// Forces the length of the vector to `new_len` .
2140+ /// /// Moves `src` into the pointed `dst`, returning the previous `dst` value .
21542141/// ///
2155- /// /// This is a low-level operation that maintains none of the normal
2156- /// /// invariants of the type. Normally changing the length of a vector
2157- /// /// is done using one of the safe operations instead, such as
2158- /// /// `truncate`, `resize`, `extend`, or `clear`.
2142+ /// /// Neither value is dropped.
2143+ /// ///
2144+ /// /// This function is semantically equivalent to [`mem::replace`] except that it
2145+ /// /// operates on raw pointers instead of references. When references are
2146+ /// /// available, [`mem::replace`] should be preferred.
21592147/// ///
21602148/// /// # Safety
21612149/// ///
2162- /// /// - `new_len` must be less than or equal to `capacity()`.
2163- /// /// - The elements at `old_len..new_len` must be initialized.
2164- /// pub unsafe fn set_len(&mut self, new_len: usize)
2150+ /// /// Behavior is undefined if any of the following conditions are violated:
2151+ /// ///
2152+ /// /// * `dst` must be [valid] for both reads and writes or `T` must be a ZST.
2153+ /// ///
2154+ /// /// * `dst` must be properly aligned.
2155+ /// ///
2156+ /// /// * `dst` must point to a properly initialized value of type `T`.
2157+ /// ///
2158+ /// /// Note that even if `T` has size `0`, the pointer must be properly aligned.
2159+ /// pub const unsafe fn replace<T>(dst: *mut T, src: T) -> T
21652160/// ```
21662161///
21672162/// ## Using `unsafe {}` blocks and `impl`s
@@ -2502,7 +2497,7 @@ mod use_keyword {}
25022497/// ```
25032498///
25042499/// `where` is available anywhere generic and lifetime parameters are available,
2505- /// as can be seen with the [`Cow`](crate:: borrow:: Cow) type from the standard
2500+ /// as can be seen with the [`Cow`](../std/ borrow/enum. Cow.html ) type from the standard
25062501/// library:
25072502///
25082503/// ```rust
0 commit comments