Skip to content

Commit 6f8bf67

Browse files
committed
Use Rust 1.75's async fn in trait instead of #[async_trait]
1 parent e89f301 commit 6f8bf67

File tree

3 files changed

+2
-5
lines changed

3 files changed

+2
-5
lines changed

src/cache.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::error::Error;
2+
use std::future::Future;
23
use std::sync::Arc;
34
use std::time::Instant;
45

@@ -10,10 +11,9 @@ const CACHE_TTL_SECS: u64 = 120;
1011

1112
pub type Cache<T> = State<Arc<RwLock<T>>>;
1213

13-
#[async_trait]
1414
pub trait Cached: Send + Sync + Clone + 'static {
1515
fn get_timestamp(&self) -> Instant;
16-
async fn fetch() -> Result<Self, Box<dyn Error + Send + Sync>>;
16+
fn fetch() -> impl Future<Output = Result<Self, Box<dyn Error + Send + Sync>>> + Send;
1717
async fn get(cache: &Cache<Self>) -> Self {
1818
let cached = cache.read().await.clone();
1919
let timestamp = cached.get_timestamp();

src/rust_version.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ impl Default for RustVersion {
4242
}
4343
}
4444

45-
#[async_trait]
4645
impl Cached for RustVersion {
4746
fn get_timestamp(&self) -> Instant {
4847
self.1
@@ -68,7 +67,6 @@ impl Default for RustReleasePost {
6867
}
6968
}
7069

71-
#[async_trait]
7270
impl Cached for RustReleasePost {
7371
fn get_timestamp(&self) -> Instant {
7472
self.1

src/teams.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ impl Default for RustTeams {
238238
}
239239
}
240240

241-
#[async_trait]
242241
impl Cached for RustTeams {
243242
fn get_timestamp(&self) -> Instant {
244243
self.1

0 commit comments

Comments
 (0)