@@ -170,7 +170,7 @@ pub fn forget_unsized<T: ?Sized>(t: T) {
170
170
///
171
171
/// The following table gives the size for primitives.
172
172
///
173
- /// Type | size_of::\ <Type>()
173
+ /// Type | ` size_of::<Type>()`
174
174
/// ---- | ---------------
175
175
/// () | 0
176
176
/// bool | 1
@@ -190,8 +190,8 @@ pub fn forget_unsized<T: ?Sized>(t: T) {
190
190
///
191
191
/// Furthermore, `usize` and `isize` have the same size.
192
192
///
193
- /// The types `*const T`, `&T`, `Box<T>`, `Option<&T>`, and `Option<Box<T>>` all have
194
- /// the same size. If `T` is Sized, all of those types have the same size as `usize`.
193
+ /// The types [ `*const T`] , `&T`, [ `Box<T>`], [ `Option<&T>`] , and `Option<Box<T>>` all have
194
+ /// the same size. If `T` is ` Sized` , all of those types have the same size as `usize`.
195
195
///
196
196
/// The mutability of a pointer does not change its size. As such, `&T` and `&mut T`
197
197
/// have the same size. Likewise for `*const T` and `*mut T`.
@@ -203,7 +203,7 @@ pub fn forget_unsized<T: ?Sized>(t: T) {
203
203
///
204
204
/// ## Size of Structs
205
205
///
206
- /// For `structs` , the size is determined by the following algorithm.
206
+ /// For `struct`s , the size is determined by the following algorithm.
207
207
///
208
208
/// For each field in the struct ordered by declaration order:
209
209
///
@@ -299,6 +299,10 @@ pub fn forget_unsized<T: ?Sized>(t: T) {
299
299
/// ```
300
300
///
301
301
/// [alignment]: align_of
302
+ /// [`*const T`]: primitive@pointer
303
+ /// [`Box<T>`]: ../../std/boxed/struct.Box.html
304
+ /// [`Option<&T>`]: crate::option::Option
305
+ ///
302
306
#[ inline( always) ]
303
307
#[ must_use]
304
308
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -311,7 +315,7 @@ pub const fn size_of<T>() -> usize {
311
315
312
316
/// Returns the size of the pointed-to value in bytes.
313
317
///
314
- /// This is usually the same as `size_of::<T>()`. However, when `T` *has* no
318
+ /// This is usually the same as [ `size_of::<T>()`] . However, when `T` *has* no
315
319
/// statically-known size, e.g., a slice [`[T]`][slice] or a [trait object],
316
320
/// then `size_of_val` can be used to get the dynamically-known size.
317
321
///
@@ -328,6 +332,8 @@ pub const fn size_of<T>() -> usize {
328
332
/// let y: &[u8] = &x;
329
333
/// assert_eq!(13, mem::size_of_val(y));
330
334
/// ```
335
+ ///
336
+ /// [`size_of::<T>()`]: size_of
331
337
#[ inline]
332
338
#[ must_use]
333
339
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -340,7 +346,7 @@ pub const fn size_of_val<T: ?Sized>(val: &T) -> usize {
340
346
341
347
/// Returns the size of the pointed-to value in bytes.
342
348
///
343
- /// This is usually the same as `size_of::<T>()`. However, when `T` *has* no
349
+ /// This is usually the same as [ `size_of::<T>()`] . However, when `T` *has* no
344
350
/// statically-known size, e.g., a slice [`[T]`][slice] or a [trait object],
345
351
/// then `size_of_val_raw` can be used to get the dynamically-known size.
346
352
///
@@ -363,6 +369,7 @@ pub const fn size_of_val<T: ?Sized>(val: &T) -> usize {
363
369
/// [`size_of_val`] on a reference to a type with an extern type tail.
364
370
/// - otherwise, it is conservatively not allowed to call this function.
365
371
///
372
+ /// [`size_of::<T>()`]: size_of
366
373
/// [trait object]: ../../book/ch17-02-trait-objects.html
367
374
/// [extern type]: ../../unstable-book/language-features/extern-types.html
368
375
///
0 commit comments