From 3505928dfb08529efd8da0593d9c8470b16e47d7 Mon Sep 17 00:00:00 2001 From: Daniel Berlin Date: Sun, 19 Mar 2023 12:37:58 -0400 Subject: [PATCH] Import formatter for alloc but no_std environments --- packed_struct/src/debug_fmt.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packed_struct/src/debug_fmt.rs b/packed_struct/src/debug_fmt.rs index a984c67..2ecc791 100644 --- a/packed_struct/src/debug_fmt.rs +++ b/packed_struct/src/debug_fmt.rs @@ -2,7 +2,13 @@ use crate::internal_prelude::v1::*; -#[cfg(any(feature="alloc", feature="std"))] +#[cfg(all(feature = "alloc", not(feature = "std")))] +use alloc::fmt::Formatter; + +#[cfg(feature = "std")] +use std::fmt::Formatter; + +#[cfg(any(feature = "alloc", feature = "std"))] pub trait PackedStructDebug { fn fmt_fields(&self, fmt: &mut Formatter) -> Result<(), FmtError>; fn packed_struct_display_header() -> &'static str;