mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 06:40:06 -04:00
Make epaint::mutex::RwLock allow ?Sized types (#4485)
`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`.
This commit is contained in:
@@ -133,14 +133,16 @@ mod rw_lock_impl {
|
|||||||
/// the feature `deadlock_detection` is turned enabled, in which case
|
/// the feature `deadlock_detection` is turned enabled, in which case
|
||||||
/// extra checks are added to detect deadlocks.
|
/// extra checks are added to detect deadlocks.
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct RwLock<T>(parking_lot::RwLock<T>);
|
pub struct RwLock<T: ?Sized>(parking_lot::RwLock<T>);
|
||||||
|
|
||||||
impl<T> RwLock<T> {
|
impl<T> RwLock<T> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn new(val: T) -> Self {
|
pub fn new(val: T) -> Self {
|
||||||
Self(parking_lot::RwLock::new(val))
|
Self(parking_lot::RwLock::new(val))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: ?Sized> RwLock<T> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn read(&self) -> RwLockReadGuard<'_, T> {
|
pub fn read(&self) -> RwLockReadGuard<'_, T> {
|
||||||
parking_lot::RwLockReadGuard::map(self.0.read(), |v| v)
|
parking_lot::RwLockReadGuard::map(self.0.read(), |v| v)
|
||||||
|
|||||||
Reference in New Issue
Block a user