diff options
| author | bors <bors@rust-lang.org> | 2023-04-16 00:07:06 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-04-16 00:07:06 +0000 |
| commit | c6fb7b9815aea87fb5ced1c683212871699c907c (patch) | |
| tree | 524293a9a11da3bee727d8b5407827b2108d1a19 /library/core/src/mem/mod.rs | |
| parent | 50b816f71f9055d6f162bec69c30b7574bb8e91a (diff) | |
| parent | a8983749bd1b92359ca6d82f52bf026b0f9b8d71 (diff) | |
| download | rust-c6fb7b9815aea87fb5ced1c683212871699c907c.tar.gz rust-c6fb7b9815aea87fb5ced1c683212871699c907c.zip | |
Auto merge of #110375 - JohnTitor:rollup-ghvdaxm, r=JohnTitor
Rollup of 8 pull requests Successful merges: - #110033 (Add 1.69.0 release notes) - #110272 (fix: skip implied bounds if unconstrained lifetime exists) - #110307 (Allow everyone to set the beta-nominated label) - #110347 (Add intra-doc links to size_of_* functions) - #110350 (Add a UI test for #79605) - #110356 (Fix `x test rust-installer` when `cargo` is set to a relative path) - #110364 (remove redundant clones) - #110366 (fix some clippy::complexity) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'library/core/src/mem/mod.rs')
| -rw-r--r-- | library/core/src/mem/mod.rs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/library/core/src/mem/mod.rs b/library/core/src/mem/mod.rs index a67df7ed557..30ec73cabf8 100644 --- a/library/core/src/mem/mod.rs +++ b/library/core/src/mem/mod.rs @@ -170,7 +170,7 @@ pub fn forget_unsized<T: ?Sized>(t: T) { /// /// The following table gives the size for primitives. /// -/// Type | size_of::\<Type>() +/// Type | `size_of::<Type>()` /// ---- | --------------- /// () | 0 /// bool | 1 @@ -190,8 +190,8 @@ pub fn forget_unsized<T: ?Sized>(t: T) { /// /// Furthermore, `usize` and `isize` have the same size. /// -/// The types `*const T`, `&T`, `Box<T>`, `Option<&T>`, and `Option<Box<T>>` all have -/// the same size. If `T` is Sized, all of those types have the same size as `usize`. +/// The types [`*const T`], `&T`, [`Box<T>`], [`Option<&T>`], and `Option<Box<T>>` all have +/// the same size. If `T` is `Sized`, all of those types have the same size as `usize`. /// /// The mutability of a pointer does not change its size. As such, `&T` and `&mut T` /// have the same size. Likewise for `*const T` and `*mut T`. @@ -203,7 +203,7 @@ pub fn forget_unsized<T: ?Sized>(t: T) { /// /// ## Size of Structs /// -/// For `structs`, the size is determined by the following algorithm. +/// For `struct`s, the size is determined by the following algorithm. /// /// For each field in the struct ordered by declaration order: /// @@ -299,6 +299,10 @@ pub fn forget_unsized<T: ?Sized>(t: T) { /// ``` /// /// [alignment]: align_of +/// [`*const T`]: primitive@pointer +/// [`Box<T>`]: ../../std/boxed/struct.Box.html +/// [`Option<&T>`]: crate::option::Option +/// #[inline(always)] #[must_use] #[stable(feature = "rust1", since = "1.0.0")] @@ -311,7 +315,7 @@ pub const fn size_of<T>() -> usize { /// Returns the size of the pointed-to value in bytes. /// -/// This is usually the same as `size_of::<T>()`. However, when `T` *has* no +/// This is usually the same as [`size_of::<T>()`]. However, when `T` *has* no /// statically-known size, e.g., a slice [`[T]`][slice] or a [trait object], /// then `size_of_val` can be used to get the dynamically-known size. /// @@ -328,6 +332,8 @@ pub const fn size_of<T>() -> usize { /// let y: &[u8] = &x; /// assert_eq!(13, mem::size_of_val(y)); /// ``` +/// +/// [`size_of::<T>()`]: size_of #[inline] #[must_use] #[stable(feature = "rust1", since = "1.0.0")] @@ -340,7 +346,7 @@ pub const fn size_of_val<T: ?Sized>(val: &T) -> usize { /// Returns the size of the pointed-to value in bytes. /// -/// This is usually the same as `size_of::<T>()`. However, when `T` *has* no +/// This is usually the same as [`size_of::<T>()`]. However, when `T` *has* no /// statically-known size, e.g., a slice [`[T]`][slice] or a [trait object], /// then `size_of_val_raw` can be used to get the dynamically-known size. /// @@ -363,6 +369,7 @@ pub const fn size_of_val<T: ?Sized>(val: &T) -> usize { /// [`size_of_val`] on a reference to a type with an extern type tail. /// - otherwise, it is conservatively not allowed to call this function. /// +/// [`size_of::<T>()`]: size_of /// [trait object]: ../../book/ch17-02-trait-objects.html /// [extern type]: ../../unstable-book/language-features/extern-types.html /// |
