Skip to content

Commit

Permalink
Make epaint::mutex::RwLock allow ?Sized types (emilk#4485)
Browse files Browse the repository at this point in the history
`parking_lot`'s `RwLock` allows this, so probably `epaint`'s `RwLock`
should too.
Although I'm not sure how much it's intended for users, rather than just
internal use by `egui`.
  • Loading branch information
crumblingstatue authored and hacknus committed Oct 30, 2024
1 parent 30aa213 commit 858e3a5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/epaint/src/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,16 @@ mod rw_lock_impl {
/// the feature `deadlock_detection` is turned enabled, in which case
/// extra checks are added to detect deadlocks.
#[derive(Default)]
pub struct RwLock<T>(parking_lot::RwLock<T>);
pub struct RwLock<T: ?Sized>(parking_lot::RwLock<T>);

impl<T> RwLock<T> {
#[inline(always)]
pub fn new(val: T) -> Self {
Self(parking_lot::RwLock::new(val))
}
}

impl<T: ?Sized> RwLock<T> {
#[inline(always)]
pub fn read(&self) -> RwLockReadGuard<'_, T> {
parking_lot::RwLockReadGuard::map(self.0.read(), |v| v)
Expand Down

0 comments on commit 858e3a5

Please sign in to comment.