mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-30 14:33:24 -04:00
rust: pin-init: docs: link Zeroable::zeroed and pin_init::zeroed in documentation
Modify the comments in the `pin_init::zeroed` and `Zeroable::zeroed` functions to cross-reference each other and make developers aware of both options. This also adapts the example code in `Zeroable::zeroed` doc comments to use that function. Suggested-by: Miguel Ojeda <ojeda@kernel.org> Link: https://lore.kernel.org/rust-for-linux/CANiq72kdCAyRUmXFcqQfkHpk1miG8Gagsn0_5U8p4WpKxv9d_g@mail.gmail.com/ Signed-off-by: Nicolás Antinori <nico.antinori.7@gmail.com> [ Fix link. - Gary ] Signed-off-by: Gary Guo <gary@garyguo.net>
This commit is contained in:
committed by
Gary Guo
parent
5bbf2b2deb
commit
9e813b9abd
@@ -1539,10 +1539,13 @@ fn init_zeroed() -> impl Init<Self>
|
||||
/// Whenever a type implements [`Zeroable`], this function should be preferred over
|
||||
/// [`core::mem::zeroed()`] or using `MaybeUninit<T>::zeroed().assume_init()`.
|
||||
///
|
||||
/// As const traits are not yet stable, [`pin_init::zeroed()`] can be used instead
|
||||
/// when initialization is required in a `const` context.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// use pin_init::{Zeroable, zeroed};
|
||||
/// use pin_init::Zeroable;
|
||||
///
|
||||
/// #[derive(Zeroable)]
|
||||
/// struct Point {
|
||||
@@ -1550,7 +1553,7 @@ fn init_zeroed() -> impl Init<Self>
|
||||
/// y: u32,
|
||||
/// }
|
||||
///
|
||||
/// let point: Point = zeroed();
|
||||
/// let point: Point = Zeroable::zeroed();
|
||||
/// assert_eq!(point.x, 0);
|
||||
/// assert_eq!(point.y, 0);
|
||||
/// ```
|
||||
@@ -1582,6 +1585,9 @@ pub fn init_zeroed<T: Zeroable>() -> impl Init<T> {
|
||||
/// Whenever a type implements [`Zeroable`], this function should be preferred over
|
||||
/// [`core::mem::zeroed()`] or using `MaybeUninit<T>::zeroed().assume_init()`.
|
||||
///
|
||||
/// While const traits remain unstable, this function serves as the `const` version of
|
||||
/// [`Zeroable::zeroed()`].
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
|
||||
Reference in New Issue
Block a user