error.rs 498 B

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