Commit 77dd798fd3f03cb8a94c19f754fd15a7c0219883

Cléo Rebert 2020-06-21T17:24:48

Merge pull request #5 from underdiskdev/master Changed a bunch of to_string() to to_owned()

diff --git a/Cargo.toml b/Cargo.toml
index 763c1dc..9ac0b71 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "totp-rs"
-version = "0.3.0"
+version = "0.3.1"
 authors = ["Cleo Rebert <cleo.rebert@gmail.com>"]
 edition = "2018"
 readme = "README.md"
diff --git a/README.md b/README.md
index a837f0a..f372113 100644
--- a/README.md
+++ b/README.md
@@ -14,18 +14,18 @@ You can then do something like:
 use std::time::SystemTime;
 use totp_rs::{Algorithm, TOTP};
 
-let username = "example".to_string();
+let username = "example".to_owned();
 let totp = TOTP::new(
     Algorithm::SHA1,
     6,
     1,
     30,
-    "supersecret".to_string().into_bytes(),
+    "supersecret".to_owned().into_bytes(),
 );
 let time = SystemTime::now()
     .duration_since(SystemTime::UNIX_EPOCH).unwrap()
     .as_secs();
-let url = totp.get_url(format!("account:{}", username), "my-org.com".to_string());
+let url = totp.get_url(format!("account:{}", username), "my-org.com".to_owned());
 println!("{}", url);
 let token = totp.generate(time);
 println!("{}", token);
@@ -43,14 +43,14 @@ You can then do something like:
 ```Rust
 use totp_rs::{Algorithm, TOTP};
 
-let username = "example".to_string();
+let username = "example".to_owned();
 let totp = TOTP::new(
     Algorithm::SHA1,
     6,
     1,
     30,
-    "supersecret".to_string().into_bytes(),
+    "supersecret".to_owned().into_bytes(),
 );
-let code = totp.get_qr(format!("account:{}", username), "my-org.com".to_string())?;
+let code = totp.get_qr(format!("account:{}", username), "my-org.com".to_owned())?;
 println!("{}", code);
 ```
diff --git a/src/lib.rs b/src/lib.rs
index 100cd4d..1cb959f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -6,18 +6,18 @@
 //! use std::time::SystemTime;
 //! use totp_rs::{Algorithm, TOTP};
 //! 
-//! let username = "example".to_string();
+//! let username = "example".to_owned();
 //! let totp = TOTP::new(
 //!     Algorithm::SHA1,
 //!     6,
 //!     1,
 //!     30,
-//!     "supersecret".to_string().into_bytes(),
+//!     "supersecret".to_owned().into_bytes(),
 //! );
 //! let time = SystemTime::now()
 //!     .duration_since(SystemTime::UNIX_EPOCH).unwrap()
 //!     .as_secs();
-//! let url = totp.get_url(format!("account:{}", username), "my-org.com".to_string());
+//! let url = totp.get_url(format!("account:{}", username), "my-org.com".to_owned());
 //! println!("{}", url);
 //! let token = totp.generate(time);
 //! println!("{}", token);
@@ -26,15 +26,15 @@
 //! ```
 //! use totp_rs::{Algorithm, TOTP};
 //!
-//! let username = "example".to_string();
+//! let username = "example".to_owned();
 //! let totp = TOTP::new(
 //!     Algorithm::SHA1,
 //!     6,
 //!     1,
 //!     30,
-//!     "supersecret".to_string().into_bytes(),
+//!     "supersecret".to_owned().into_bytes(),
 //! );
-//! let code = totp.get_qr(format!("account:{}", username), "my-org.com".to_string())?;
+//! let code = totp.get_qr(format!("account:{}", username), "my-org.com".to_owned())?;
 //! println!("{}", code);
 //! ```
 
@@ -143,9 +143,9 @@ impl TOTP {
     pub fn get_url(&self, label: String, issuer: String) -> String {
         let algorithm: String;
         match self.algorithm {
-            Algorithm::SHA1 => algorithm = "SHA1".to_string(),
-            Algorithm::SHA256 => algorithm = "SHA256".to_string(),
-            Algorithm::SHA512 => algorithm = "SHA512".to_string(),
+            Algorithm::SHA1 => algorithm = "SHA1".to_owned(),
+            Algorithm::SHA256 => algorithm = "SHA256".to_owned(),
+            Algorithm::SHA512 => algorithm = "SHA512".to_owned(),
         }
         format!(
             "otpauth://totp/{}?secret={}&issuer={}&digits={}&algorithm={}",