diff options
| author | Teddy Wing | 2017-11-12 20:16:54 +0100 | 
|---|---|---|
| committer | Teddy Wing | 2017-11-12 20:16:54 +0100 | 
| commit | b06e3fe2f1bcf7fa897648ab79e301ccab256ac8 (patch) | |
| tree | 2c890e557c7b09dc841dc59cda5f5a1a2f3cc1ba | |
| parent | 98ff2f8a24f0d32043b4de9b5671a4d882a6e903 (diff) | |
| download | kipper-b06e3fe2f1bcf7fa897648ab79e301ccab256ac8.tar.bz2 | |
Convert a bunch of `to_string()`s to `to_owned()`
I had used `to_owned()` previously in other projects, but after looking
up the difference (again probably), I decided that it seems better to
use `to_owned()`.
References:
https://users.rust-lang.org/t/to-string-vs-to-owned-for-string-literals/1441/6
http://www.lowlevelmanager.com/2016/02/rust-tostring-vs-toowned-for-string.html
| -rw-r--r-- | src/af83.rs | 8 | ||||
| -rw-r--r-- | src/github.rs | 12 | ||||
| -rw-r--r-- | src/jenkins.rs | 36 | 
3 files changed, 28 insertions, 28 deletions
| diff --git a/src/af83.rs b/src/af83.rs index 5a56c36..236574f 100644 --- a/src/af83.rs +++ b/src/af83.rs @@ -14,10 +14,10 @@ mod tests {      #[test]      fn job_name_is_branch_appended_by_commit_sha_prefix() {          let commit_ref = CommitRef { -            owner: "sybil".to_string(), -            repo: "sybil-system".to_string(), -            sha: "159f8769b897ed7774700d0b2777def8ac838b8f".to_string(), -            branch: "5912-make-logo-bigger".to_string(), +            owner: "sybil".to_owned(), +            repo: "sybil-system".to_owned(), +            sha: "159f8769b897ed7774700d0b2777def8ac838b8f".to_owned(), +            branch: "5912-make-logo-bigger".to_owned(),          };          assert_eq!( diff --git a/src/github.rs b/src/github.rs index 91e9266..16f1cde 100644 --- a/src/github.rs +++ b/src/github.rs @@ -93,19 +93,19 @@ mod tests {              .create();          let commit_ref = CommitRef { -            owner: "octocat".to_string(), -            repo: "Hello-World".to_string(), -            sha: "6dcb09b5b57875f334f61aebed695e2e4193db5e".to_string(), -            branch: "not-used".to_string(), +            owner: "octocat".to_owned(), +            repo: "Hello-World".to_owned(), +            sha: "6dcb09b5b57875f334f61aebed695e2e4193db5e".to_owned(), +            branch: "not-used".to_owned(),          };          update_commit_status(              &"token".to_owned(),              &commit_ref,              &CommitStatus::Success, -            "https://jenkins.example.com/job/octocat/3".to_string(), +            "https://jenkins.example.com/job/octocat/3".to_owned(),              None, -            "continuous-integration/jenkins".to_string() +            "continuous-integration/jenkins".to_owned()          ).expect("Failed to update commit status");          mock.assert(); diff --git a/src/jenkins.rs b/src/jenkins.rs index f2da0d2..ec0f1d0 100644 --- a/src/jenkins.rs +++ b/src/jenkins.rs @@ -114,7 +114,7 @@ pub fn find_and_track_build_and_update_status(                      &commit_status,                      job_url.clone(),                      None, -                    "continuous-integration/jenkins".to_string() +                    "continuous-integration/jenkins".to_owned()                  ).expect(                      format!(                          "GitHub pending status update failed for {}/{} {}.", @@ -141,8 +141,8 @@ pub fn find_and_track_build_and_update_status(                              &commit_ref,                              &github::CommitStatus::Error,                              job_url.clone(), -                            Some("The status checker timed out.".to_string()), -                            "continuous-integration/jenkins".to_string() +                            Some("The status checker timed out.".to_owned()), +                            "continuous-integration/jenkins".to_owned()                          ).expect(                              format!(                                  "GitHub timeout error status update failed for {}/{} {}.", @@ -172,7 +172,7 @@ pub fn find_and_track_build_and_update_status(                              &job.result.commit_status(),                              job_url.clone(),                              None, -                            "continuous-integration/jenkins".to_string() +                            "continuous-integration/jenkins".to_owned()                          ).expect(                              format!(                                  "GitHub status update failed for {}/{} {}.", @@ -294,7 +294,7 @@ mod tests {          let payload = r#"{              "displayName": "3296-fix-typo-700d0",              "result": "SUCCESS" -        }"#.to_string(); +        }"#.to_owned();          let job = Job::new(payload).expect("Failed to create job from payload"); @@ -361,7 +361,7 @@ mod tests {          ).expect("Failed to request job");          let expected = Job { -            display_name: "2388-delete-the-codes-391af".to_string(), +            display_name: "2388-delete-the-codes-391af".to_owned(),              result: JobStatus::Success,          }; @@ -372,15 +372,15 @@ mod tests {      #[test]      fn job_for_commit_returns_true_when_commit_matches_job() {          let job = Job { -            display_name: "1753-fix-everything-b4a28".to_string(), +            display_name: "1753-fix-everything-b4a28".to_owned(),              result: JobStatus::Pending,          };          let commit_ref = CommitRef { -            owner: "uso".to_string(), -            repo: "vivid-system".to_string(), -            sha: "b4a286e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c".to_string(), -            branch: "1753-fix-everything".to_string(), +            owner: "uso".to_owned(), +            repo: "vivid-system".to_owned(), +            sha: "b4a286e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c".to_owned(), +            branch: "1753-fix-everything".to_owned(),          };          assert_eq!(job_for_commit(&job, &commit_ref), true); @@ -389,15 +389,15 @@ mod tests {      #[test]      fn job_for_commit_returns_false_when_commit_doesnt_match_job() {          let job = Job { -            display_name: "5234-eliminate-widgetmacallit-5a28c".to_string(), +            display_name: "5234-eliminate-widgetmacallit-5a28c".to_owned(),              result: JobStatus::Success,          };          let commit_ref = CommitRef { -            owner: "uso".to_string(), -            repo: "vivid-system".to_string(), -            sha: "b4a286e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c".to_string(), -            branch: "1753-fix-everything".to_string(), +            owner: "uso".to_owned(), +            repo: "vivid-system".to_owned(), +            sha: "b4a286e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c".to_owned(), +            branch: "1753-fix-everything".to_owned(),          };          assert_eq!(job_for_commit(&job, &commit_ref), false); @@ -406,7 +406,7 @@ mod tests {      #[test]      fn result_from_job_is_success() {          assert_eq!( -            result_from_job(Some("SUCCESS".to_string())), +            result_from_job(Some("SUCCESS".to_owned())),              JobStatus::Success          );      } @@ -414,7 +414,7 @@ mod tests {      #[test]      fn result_from_job_is_failure() {          assert_eq!( -            result_from_job(Some("FAILURE".to_string())), +            result_from_job(Some("FAILURE".to_owned())),              JobStatus::Failure          );      } | 
