fix: change function parameters into references

master
Aravinth Manivannan 2022-02-14 22:41:07 +05:30
parent 303a430113
commit 79704087f6
Signed by: realaravinth
GPG Key ID: AD9F0F08E855ED88
2 changed files with 14 additions and 14 deletions

View File

@ -54,15 +54,15 @@ pub struct Password {
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
/// Data required to create a gist in DB /// Data required to create a gist in DB
/// creation date defaults to time at which creation method is called /// creation date defaults to time at which creation method is called
pub struct CreateGist { pub struct CreateGist<'a> {
/// owner of the gist /// owner of the gist
pub owner: String, pub owner: &'a str,
/// description of the gist /// description of the gist
pub description: Option<String>, pub description: Option<&'a str>,
/// public ID of the gist /// public ID of the gist
pub public_id: String, pub public_id: &'a str,
/// gist visibility /// gist visibility
pub visibility: GistVisibility, pub visibility: &'a GistVisibility,
} }
/// Gist visibility /// Gist visibility
@ -144,13 +144,13 @@ pub struct GistComment {
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
/// Data required to create a comment on a Gist /// Data required to create a comment on a Gist
/// creation date defaults to time at which creation method is called /// creation date defaults to time at which creation method is called
pub struct CreateGistComment { pub struct CreateGistComment<'a> {
/// owner of the comment /// owner of the comment
pub owner: String, pub owner: &'a str,
/// public ID of the gist on which this comment was made /// public ID of the gist on which this comment was made
pub gist_public_id: String, pub gist_public_id: &'a str,
/// comment text /// comment text
pub comment: String, pub comment: &'a str,
} }
/// payload to register a user with username _and_ email /// payload to register a user with username _and_ email

View File

@ -69,10 +69,10 @@ pub async fn gists_work<T: GistDatabase>(
} }
fn assert_gists(lhs: &CreateGist, rhs: &Gist) { 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.owner, rhs.owner);
assert_eq!(lhs.public_id, rhs.public_id); 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; let _ = db.delete_account(username).await;
@ -86,9 +86,9 @@ pub async fn gists_work<T: GistDatabase>(
let create_gist = CreateGist { let create_gist = CreateGist {
owner: username.into(), owner: username.into(),
description: Some("foo".to_string()), description: Some("foo"),
public_id: public_id.to_string(), public_id,
visibility: GistVisibility::Public, visibility: &GistVisibility::Public,
}; };
assert!(!db.gist_exists(&create_gist.public_id).await.unwrap()); assert!(!db.gist_exists(&create_gist.public_id).await.unwrap());