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