Skip to content

Commit

Permalink
style: simplify return type for infallible constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
austinhartzheim committed Dec 25, 2024
1 parent 09ff792 commit c70e0b5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 deletions src/guard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use std::ops::Deref;

use crate::instance::InstanceVersion;
use crate::state::State;
use crate::synchronizer::SynchronizerError;

/// An RAII implementation of a “scoped read lock” of a `State`
pub(crate) struct ReadGuard<'a> {
Expand All @@ -27,12 +26,9 @@ pub(crate) struct ReadGuard<'a> {

impl<'a> ReadGuard<'a> {
/// Creates new `ReadGuard` with specified parameters
pub(crate) fn new(
state: &'a mut State,
version: InstanceVersion,
) -> Result<Self, SynchronizerError> {
pub(crate) fn new(state: &'a mut State, version: InstanceVersion) -> Self {
state.rlock(version);
Ok(ReadGuard { version, state })
ReadGuard { version, state }
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/synchronizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ where
let version = state.version()?;

// create and lock state guard for reading
let guard = ReadGuard::new(state, version)?;
let guard = ReadGuard::new(state, version);

// fetch data for current version from mapped memory
let (data, switched) = self.data_container.data(version)?;
Expand Down

0 comments on commit c70e0b5

Please sign in to comment.