Skip to content

Commit

Permalink
Merge pull request #1 from mkroening/debug-impl
Browse files Browse the repository at this point in the history
feat: remove Debug trait bound from Debug impl
  • Loading branch information
mkroening committed Aug 31, 2023
2 parents 3a6fc83 + 988ae6f commit c3b36d9
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 c3b36d9

Please sign in to comment.