Skip to content

Commit

Permalink
Simplify lifetimes of ReadlineGuard
Browse files Browse the repository at this point in the history
The lifetimes that we use on our ReadlineGuard type are unnecessarily
complicated: we only need a single lifetime and we can elide it in impl
that don't actually use said lifetime. Simplify the code accordingly.
  • Loading branch information
d-e-s-o committed Mar 29, 2024
1 parent e26c99d commit 104b9af
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lib.rs
Expand Up @@ -159,12 +159,12 @@ impl<T> Locked for Mutex<T> {


/// A wrapper for `MutexGuard` ensuring that our libreadline state is read back before dropping.
struct ReadlineGuard<'data, 'slf> {
struct ReadlineGuard<'data> {
_guard: MutexGuard<'data, Id>,
state: RefMut<'slf, readline_state>,
state: RefMut<'data, readline_state>,
}

impl<'data, 'slf> Drop for ReadlineGuard<'data, 'slf> {
impl Drop for ReadlineGuard<'_> {
fn drop(&mut self) {
// Before unlocking (by virtue of dropping the embedded guard)
// always make sure to read back the most recent version of the
Expand Down Expand Up @@ -356,7 +356,7 @@ impl Readline {
}

/// Activate this context.
fn activate<'slf, 'data: 'slf>(&'slf self) -> ReadlineGuard<'data, 'slf> {
fn activate(&self) -> ReadlineGuard<'_> {
let mut guard = Self::mutex().lock().unwrap();
let state = self.state.borrow_mut();

Expand Down

0 comments on commit 104b9af

Please sign in to comment.