mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-06-21 15:43:21 +02:00
be7ea321a2
There was a recent request in kernel [1] to mark as `#[inline]` the
simple `From::from()` functions implemented for `Error`.
Thus mark all of the existing
impl From<...> for Error {
fn from(err: ...) -> Self {
...
}
}
functions as `#[inline]`.
While in pin-init crate the relevant code is just examples, it
nevertheless does not hurt to use good practice for them.
Suggested-by: Gary Guo <gary@garyguo.net>
Link: https://lore.kernel.org/all/8403c8b7a832b5274743816eb77abfa4@garyguo.net/ [1]
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
[ Reworded commit message - Gary ]
Link: https://patch.msgid.link/20260428-pin-init-sync-v1-1-07f9bd3859fb@garyguo.net
Signed-off-by: Gary Guo <gary@garyguo.net>
32 lines
526 B
Rust
32 lines
526 B
Rust
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
|
|
#![cfg_attr(feature = "alloc", feature(allocator_api))]
|
|
|
|
use core::convert::Infallible;
|
|
|
|
#[cfg(feature = "alloc")]
|
|
use std::alloc::AllocError;
|
|
|
|
#[derive(Debug)]
|
|
pub struct Error;
|
|
|
|
impl From<Infallible> for Error {
|
|
#[inline]
|
|
fn from(e: Infallible) -> Self {
|
|
match e {}
|
|
}
|
|
}
|
|
|
|
#[cfg(feature = "alloc")]
|
|
impl From<AllocError> for Error {
|
|
#[inline]
|
|
fn from(_: AllocError) -> Self {
|
|
Self
|
|
}
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
fn main() {
|
|
let _ = Error;
|
|
}
|