mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 04:34:03 +02:00
rust: pin-init: mark pin_init::zeroed and Zeroable::zeroed as #[inline]
The `pin_init::zeroed` function is a trivial wrapper around
`unsafe { core::mem::zeroed() }`, whereas `Zeroable::zeroed` is a trivial
wrapper around `pin_init::zeroed`. Mark them both as `#[inline]` to avoid
generating unnecessary symbols for them.
Signed-off-by: Nicolás Antinori <nico.antinori.7@gmail.com>
Signed-off-by: Gary Guo <gary@garyguo.net>
This commit is contained in:
parent
9e813b9abd
commit
6d0795b507
|
|
@ -1557,6 +1557,7 @@ fn init_zeroed() -> impl Init<Self>
|
|||
/// assert_eq!(point.x, 0);
|
||||
/// assert_eq!(point.y, 0);
|
||||
/// ```
|
||||
#[inline]
|
||||
fn zeroed() -> Self
|
||||
where
|
||||
Self: Sized,
|
||||
|
|
@ -1603,6 +1604,7 @@ pub fn init_zeroed<T: Zeroable>() -> impl Init<T> {
|
|||
/// assert_eq!(point.x, 0);
|
||||
/// assert_eq!(point.y, 0);
|
||||
/// ```
|
||||
#[inline]
|
||||
pub const fn zeroed<T: Zeroable>() -> T {
|
||||
// SAFETY:By the type invariants of `Zeroable`, all zeroes is a valid bit pattern for `T`.
|
||||
unsafe { core::mem::zeroed() }
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user