Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1// SPDX-License-Identifier: Apache-2.0 OR MIT
2
3#![cfg_attr(feature = "alloc", feature(allocator_api))]
4
5use core::convert::Infallible;
6
7#[cfg(feature = "alloc")]
8use std::alloc::AllocError;
9
10#[derive(Debug)]
11pub struct Error;
12
13impl From<Infallible> for Error {
14 fn from(e: Infallible) -> Self {
15 match e {}
16 }
17}
18
19#[cfg(feature = "alloc")]
20impl From<AllocError> for Error {
21 fn from(_: AllocError) -> Self {
22 Self
23 }
24}
25
26#[allow(dead_code)]
27fn main() {
28 let _ = Error;
29}