projects/linux·blob master · refs

31 lines · 526 B

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 #[inline]
15 fn from(e: Infallible) -> Self {
16 match e {}
17 }
18}
19
20#[cfg(feature = "alloc")]
21impl From<AllocError> for Error {
22 #[inline]
23 fn from(_: AllocError) -> Self {
24 Self
25 }
26}
27
28#[allow(dead_code)]
29fn main() {
30 let _ = Error;
31}