Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions arcshift/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.4.3

Fix Debug impl of ArcShift, so that it honors "{:#?}" format strings.

## 0.4.2

Support rust 1.75 (0.4.1 regressed to require newer rust).
Expand Down
4 changes: 3 additions & 1 deletion arcshift/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,9 @@ where
T: Debug,
{
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
write!(f, "ArcShift({:?})", self.shared_non_reloading_get())
f.debug_tuple("ArcShift")
.field(&self.shared_non_reloading_get())
.finish()
}
}

Expand Down
22 changes: 21 additions & 1 deletion arcshift/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ use std::hint::black_box;
use std::mem::MaybeUninit;
use std::string::ToString;
use std::sync::atomic::AtomicUsize;
use std::thread;
use std::time::Duration;
use std::vec;
use std::{format, thread};

mod custom_fuzz;
pub(crate) mod leak_detection;
Expand Down Expand Up @@ -2656,6 +2656,26 @@ fn simple_threading_try_into_inner3() {
});
}

#[test]
fn check_debug_impls() {
#[derive(Debug)]
struct Sample {
x: u32,
y: bool,
}

let x = ArcShift::new(Sample { x: 42, y: false });
let weak = ArcShift::downgrade(&x);

assert_eq!(format!("{:?}", x), "ArcShift(Sample { x: 42, y: false })");
assert_eq!(format!("{:?}", weak), "ArcShiftWeak(..)");
assert_eq!(
format!("{:#?}", x),
"ArcShift(\n Sample {\n x: 42,\n y: false,\n },\n)"
);
assert_eq!(format!("{:#?}", weak), "ArcShiftWeak(..)");
}

/*
This does not compile, nor should it compile.
ArcShift<T:'a> must be invariant in 'a.
Expand Down
Loading