Skip to content

Commit

Permalink
feat: remove Debug trait bound from Debug impl
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Kröning <[email protected]>
  • Loading branch information
mkroening committed Aug 31, 2023
1 parent 3a6fc83 commit 988ae6f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#![no_std]

use core::cell::UnsafeCell;
use core::fmt;

use call_once::CallOnce;

Expand Down Expand Up @@ -52,12 +53,20 @@ use call_once::CallOnce;
/// assert_eq!(NUMBER.take(), Some(&mut 5));
/// assert_eq!(NUMBER.take(), None);
/// ```
#[derive(Debug)]
pub struct TakeStatic<T: ?Sized> {
taken: CallOnce,
data: UnsafeCell<T>,
}

impl<T: ?Sized> fmt::Debug for TakeStatic<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("TakeStatic")
.field("taken", &self.taken)
.field("data", &&self.data)
.finish()
}
}

// SAFETY: This is safe even without `Send` bound,
// as `TakeStatics` can only ever be constructed at compile-time for statics.
// The consteval “thread” is not considered part of the `Send` contract.
Expand Down

0 comments on commit 988ae6f

Please sign in to comment.