Skip to content

Commit 493d504

Browse files
authored
Merge pull request #228 from Imberflur/fix-ref-debug
Update Debug impls for cell::Ref/cell::RefMut to show value (and bump MSRV)
2 parents 9708b7f + 6b75481 commit 493d504

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- nightly
2121
- beta
2222
- stable
23-
- 1.56.1 # MSRV
23+
- 1.59.0 # MSRV
2424

2525
timeout-minutes: 10
2626

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
* Increase MSRV to 1.59.0 because of `rayon-core v1.11.0`.
6+
37
## 0.14.1 (2022-07-14)
48

59
* Undo performance regression from removing `hashbrown` by using `ahash` hasher

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ categories = ["concurrency"]
1414
license = "MIT OR Apache-2.0"
1515
exclude = ["bors.toml", ".travis.yml"]
1616
edition = "2021"
17-
rust-version = "1.56.1"
17+
rust-version = "1.59.0"
1818

1919
[dependencies]
2020
ahash = "0.7.6"

src/cell.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use core::ptr::NonNull;
55
use std::{
66
cell::UnsafeCell,
77
error::Error,
8-
fmt::{Display, Error as FormatError, Formatter},
8+
fmt::{Debug, Display, Error as FormatError, Formatter},
99
ops::{Deref, DerefMut},
1010
sync::atomic::{AtomicUsize, Ordering},
1111
usize,
@@ -41,7 +41,6 @@ impl Error for InvalidBorrow {
4141
/// An immutable reference to data in a `TrustCell`.
4242
///
4343
/// Access the value via `std::ops::Deref` (e.g. `*val`)
44-
#[derive(Debug)]
4544
pub struct Ref<'a, T: ?Sized + 'a> {
4645
flag: &'a AtomicUsize,
4746
value: NonNull<T>,
@@ -135,10 +134,15 @@ impl<'a, T: ?Sized> Clone for Ref<'a, T> {
135134
}
136135
}
137136

137+
impl<'a, T: ?Sized + Debug> Debug for Ref<'a, T> {
138+
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FormatError> {
139+
<T as Debug>::fmt(self, f)
140+
}
141+
}
142+
138143
/// A mutable reference to data in a `TrustCell`.
139144
///
140145
/// Access the value via `std::ops::DerefMut` (e.g. `*val`)
141-
#[derive(Debug)]
142146
pub struct RefMut<'a, T: ?Sized + 'a> {
143147
flag: &'a AtomicUsize,
144148
value: NonNull<T>,
@@ -245,6 +249,12 @@ impl<'a, T: ?Sized> Drop for RefMut<'a, T> {
245249
}
246250
}
247251

252+
impl<'a, T: ?Sized + Debug> Debug for RefMut<'a, T> {
253+
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), FormatError> {
254+
<T as Debug>::fmt(self, f)
255+
}
256+
}
257+
248258
/// A custom cell container that is a `RefCell` with thread-safety.
249259
#[derive(Debug)]
250260
pub struct TrustCell<T> {

0 commit comments

Comments
 (0)