Skip to content

Commit e041be1

Browse files
committed
feat(core): require Default for *LockState, add IntervalRwLockCore::INIT
1 parent 580719a commit e041be1

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/core/mod.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,25 @@ pub trait IntervalRwLockCore {
4141

4242
/// The storage for per-lock data. Dropping it while it has an associated
4343
/// lock will cause a panic.
44-
type ReadLockState;
44+
type ReadLockState: Default;
4545

4646
/// Ditto for writer locks.
47-
type WriteLockState;
47+
type WriteLockState: Default;
4848

4949
/// Ditto for non-blocking reader locks.
50-
type TryReadLockState;
50+
type TryReadLockState: Default;
5151

5252
/// Ditto for non-blocking writer locks.
53-
type TryWriteLockState;
53+
type TryWriteLockState: Default;
5454

5555
/// Created by a `LockCallback` implementation when a lock operation is
5656
/// blocked in the middle. It will later be passed to [`UnlockCallback::
5757
/// complete`] when the lock completes.
5858
type InProgress;
5959

60+
/// The initializer.
61+
const INIT: Self;
62+
6063
/// Acquire a reader lock.
6164
fn lock_read<Callback: LockCallback<Self::InProgress>>(
6265
self: Pin<&mut Self>,

src/core/rbtree.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,8 @@ where
352352
type TryWriteLockState = TryWriteLockState<Index, Priority, InProgress>;
353353
type InProgress = InProgress;
354354

355+
const INIT: Self = Self::new();
356+
355357
fn lock_read<Callback: LockCallback<Self::InProgress>>(
356358
self: Pin<&mut Self>,
357359
range: Range<Self::Index>,

0 commit comments

Comments
 (0)