Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/rust/pin-init/examples/error.rs
29278 views
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 {
14
fn from(e: Infallible) -> Self {
15
match e {}
16
}
17
}
18
19
#[cfg(feature = "alloc")]
20
impl From<AllocError> for Error {
21
fn from(_: AllocError) -> Self {
22
Self
23
}
24
}
25
26
#[allow(dead_code)]
27
fn main() {
28
let _ = Error;
29
}
30
31