From 54522ba8c62ce6d1e0884d693197b8ab47267024 Mon Sep 17 00:00:00 2001 From: cahe Date: Sat, 31 Oct 2020 15:11:55 -0300 Subject: [PATCH] Simplify lifetime usage of default repository --- src/base/robots.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/base/robots.rs b/src/base/robots.rs index 652e806..bba534d 100644 --- a/src/base/robots.rs +++ b/src/base/robots.rs @@ -6,29 +6,29 @@ pub struct Robot { pub name: String, } -pub trait DefaultRepository<'f> { - fn add(&'f mut self, r: Robot) -> TraitFuture<'f, Result>; - fn get_by_id(&'f mut self, id: i64) -> TraitFuture<'f, Result>; - fn update(&'f mut self, r: Robot) -> TraitFuture>; - fn delete(&'f mut self, id: i64) -> TraitFuture>; +pub trait DefaultRepository<'c> { + fn add(&'c mut self, r: Robot) -> TraitFuture>; + fn get_by_id(&'c mut self, id: i64) -> TraitFuture>; + fn update(&'c mut self, r: Robot) -> TraitFuture>; + fn delete(&'c mut self, id: i64) -> TraitFuture>; } -pub async fn add<'a>( - repo: &'a mut impl DefaultRepository<'a>, +pub async fn add<'c>( + repo: &'c mut impl DefaultRepository<'c>, r: Robot, ) -> Result { repo.add(r).await } -pub async fn update<'a>( - repo: &'a mut impl DefaultRepository<'a>, +pub async fn update<'c>( + repo: &'c mut impl DefaultRepository<'c>, r: Robot, ) -> Result<(), HandlingError> { repo.update(r).await } -pub async fn delete<'a>( - repo: &'a mut impl DefaultRepository<'a>, +pub async fn delete<'c>( + repo: &'c mut impl DefaultRepository<'c>, id: i64, ) -> Result<(), HandlingError> { repo.delete(id).await