Skip to content

Commit

Permalink
Fix clippy,
Browse files Browse the repository at this point in the history
Fix unnecessary qualifications
  • Loading branch information
ChrisRega committed Oct 17, 2024
1 parent 8faecee commit ae3e219
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lazy_async_promise"
version = "0.5.0"
version = "0.6.0"
edition = "2021"
authors = ["Christopher Regali <christopher.regali@vdop.org>"]
license = "MIT"
Expand All @@ -12,8 +12,8 @@ exclude = [".github"]
description = "Primitives for lazily getting data from futures with tokio for immediate mode guis"

[dependencies]
tokio = {version="1", features=["rt-multi-thread", "sync"]}
tokio = { version = "1", features = ["rt-multi-thread", "sync"] }

[dev-dependencies]
tokio = {version="1", features=["rt-multi-thread", "sync", "time", "fs", "macros"]}
tokio = { version = "1", features = ["rt-multi-thread", "sync", "time", "fs", "macros"] }

5 changes: 1 addition & 4 deletions src/immediatevalueprogress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,7 @@ impl<T: Send + 'static, M> ProgressTrackedImValProm<T, M> {

/// Get the current progress
pub fn get_progress(&self) -> Progress {
self.status
.last()
.map(|p| p.progress)
.unwrap_or(Progress::default())
self.status.last().map(|p| p.progress).unwrap_or_default()
}
}

Expand Down
9 changes: 5 additions & 4 deletions src/lazyvalue.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::{
box_future_factory, BoxedFutureFactory, DataState, DirectCacheAccess, Message, Promise,
};
use std::{fmt::Debug, mem};
use std::future::Future;
use std::{fmt::Debug, mem};
use tokio::sync::mpsc::{channel, Receiver, Sender};

/// # A single lazy-async updated value
Expand Down Expand Up @@ -89,7 +89,7 @@ impl<T: Debug> DirectCacheAccess<T, String> for LazyValuePromise<T> {

fn get_result(&self) -> Option<Result<&T, &String>> {
if let DataState::UpToDate = self.state {
self.cache.as_ref().map(|cache| Ok(cache))
self.cache.as_ref().map(Ok)
} else if let DataState::Error(error) = &self.state {
Some(Err(error))
} else {
Expand All @@ -111,9 +111,10 @@ impl<T: Debug> DirectCacheAccess<T, String> for LazyValuePromise<T> {
fn take_result(&mut self) -> Option<Result<T, String>> {
if self.state == DataState::UpToDate {
self.state = DataState::Uninitialized;
self.cache.take().map(|cache|Ok(cache))
self.cache.take().map(|cache| Ok(cache))
} else if let DataState::Error(_) = self.state {
let DataState::Error(err) = mem::replace(&mut self.state, DataState::Uninitialized) else {
let DataState::Error(err) = mem::replace(&mut self.state, DataState::Uninitialized)
else {
unreachable!();
};
Some(Err(err))
Expand Down
5 changes: 3 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
//! - You want several items of the same kind / streamed? Use: [`LazyVecPromise`]
//! - You want one item when ready and need lazy evaluation or have intermediate results? Use: [`LazyValuePromise`]
#![deny(missing_docs)]
#![deny(unused_qualifications)]
#![deny(deprecated)]
#![deny(absolute_paths_not_starting_with_crate)]
#![deny(unstable_features)]
Expand Down Expand Up @@ -84,7 +83,9 @@ pub trait DirectCacheAccess<T, E> {
}

/// Blanket implementation for any `Option<DirectCacheAccess<T>>` allows for better handling of option-laziness
impl<T: Send + 'static, E: Send + 'static, A: DirectCacheAccess<T, E>> DirectCacheAccess<T, E> for Option<A> {
impl<T: Send + 'static, E: Send + 'static, A: DirectCacheAccess<T, E>> DirectCacheAccess<T, E>
for Option<A>
{
fn get_value_mut(&mut self) -> Option<&mut T> {
self.as_mut().and_then(|inner| inner.get_value_mut())
}
Expand Down

0 comments on commit ae3e219

Please sign in to comment.