From 79704087f6701bec158cdbba1dce4a982375aea5 Mon Sep 17 00:00:00 2001 From: realaravinth Date: Mon, 14 Feb 2022 22:41:07 +0530 Subject: [PATCH] fix: change function parameters into references --- database/db-core/src/lib.rs | 18 +++++++++--------- database/db-core/src/tests.rs | 10 +++++----- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/database/db-core/src/lib.rs b/database/db-core/src/lib.rs index fde80a5..f97fc9b 100644 --- a/database/db-core/src/lib.rs +++ b/database/db-core/src/lib.rs @@ -54,15 +54,15 @@ pub struct Password { #[derive(Clone, Debug)] /// Data required to create a gist in DB /// creation date defaults to time at which creation method is called -pub struct CreateGist { +pub struct CreateGist<'a> { /// owner of the gist - pub owner: String, + pub owner: &'a str, /// description of the gist - pub description: Option, + pub description: Option<&'a str>, /// public ID of the gist - pub public_id: String, + pub public_id: &'a str, /// gist visibility - pub visibility: GistVisibility, + pub visibility: &'a GistVisibility, } /// Gist visibility @@ -144,13 +144,13 @@ pub struct GistComment { #[derive(Clone, Debug)] /// Data required to create a comment on a Gist /// creation date defaults to time at which creation method is called -pub struct CreateGistComment { +pub struct CreateGistComment<'a> { /// owner of the comment - pub owner: String, + pub owner: &'a str, /// public ID of the gist on which this comment was made - pub gist_public_id: String, + pub gist_public_id: &'a str, /// comment text - pub comment: String, + pub comment: &'a str, } /// payload to register a user with username _and_ email diff --git a/database/db-core/src/tests.rs b/database/db-core/src/tests.rs index 608cdfc..d967dc7 100644 --- a/database/db-core/src/tests.rs +++ b/database/db-core/src/tests.rs @@ -69,10 +69,10 @@ pub async fn gists_work( } fn assert_gists(lhs: &CreateGist, rhs: &Gist) { - assert_eq!(lhs.description, rhs.description); + assert_eq!(lhs.description.as_ref().unwrap(), rhs.description.as_ref().unwrap()); assert_eq!(lhs.owner, rhs.owner); assert_eq!(lhs.public_id, rhs.public_id); - assert_eq!(lhs.visibility, rhs.visibility); + assert_eq!(lhs.visibility, &rhs.visibility); } let _ = db.delete_account(username).await; @@ -86,9 +86,9 @@ pub async fn gists_work( let create_gist = CreateGist { owner: username.into(), - description: Some("foo".to_string()), - public_id: public_id.to_string(), - visibility: GistVisibility::Public, + description: Some("foo"), + public_id, + visibility: &GistVisibility::Public, }; assert!(!db.gist_exists(&create_gist.public_id).await.unwrap());