refactor: general small refactors to simplify code

- Remove `expect` in favor of `unwrap` when the `Result`'s error variant
  contains the info in the `expect` anyway (eg. when locking things).
  The line number/context are given by the backtrace.
- Remove over-specification of types (`&T` instead of
  `&RWReadLockGuard`)
- Put reused values into constants
- `FromStr` instead of manual function
- Change `if let Some(()) = ...` to `if T.is_some()`
This commit is contained in:
Thomas Frans
2024-02-01 22:05:43 +01:00
committed by Henrik Friedrichsen
parent c5d666f35c
commit 3c8e546445
12 changed files with 97 additions and 96 deletions

View File

@@ -423,7 +423,7 @@ impl Queue {
/// Set the current repeat behavior and save it to the configuration.
pub fn set_repeat(&self, new: RepeatSetting) {
self.cfg.with_state_mut(|mut s| s.repeat = new);
self.cfg.with_state_mut(|s| s.repeat = new);
}
/// Get the current shuffle behavior.
@@ -457,7 +457,7 @@ impl Queue {
/// Set the current shuffle behavior.
pub fn set_shuffle(&self, new: bool) {
self.cfg.with_state_mut(|mut s| s.shuffle = new);
self.cfg.with_state_mut(|s| s.shuffle = new);
if new {
self.generate_random_order();
} else {