From f7680752e7c8057fa65f7166355f2b3660c7a18f Mon Sep 17 00:00:00 2001 From: Rob Walker Date: Wed, 8 May 2019 23:00:48 -0700 Subject: [PATCH] make gen_keypair_file take &str (#4232) automerge --- keygen/src/keygen.rs | 2 +- sdk/src/signature.rs | 6 +++--- wallet/src/main.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/keygen/src/keygen.rs b/keygen/src/keygen.rs index befdb714d..8f51cd1f3 100644 --- a/keygen/src/keygen.rs +++ b/keygen/src/keygen.rs @@ -81,7 +81,7 @@ fn main() -> Result<(), Box> { path.to_str().unwrap() }; - let serialized_keypair = gen_keypair_file(outfile.to_string())?; + let serialized_keypair = gen_keypair_file(outfile)?; if outfile == "-" { println!("{}", serialized_keypair); } diff --git a/sdk/src/signature.rs b/sdk/src/signature.rs index 6423cd090..85674064d 100644 --- a/sdk/src/signature.rs +++ b/sdk/src/signature.rs @@ -100,12 +100,12 @@ pub fn read_keypair(path: &str) -> Result> { Ok(keypair) } -pub fn gen_keypair_file(outfile: String) -> Result> { +pub fn gen_keypair_file(outfile: &str) -> Result> { let keypair_bytes = Keypair::new().to_bytes(); let serialized = serde_json::to_string(&keypair_bytes.to_vec())?; if outfile != "-" { - if let Some(outdir) = Path::new(&outfile).parent() { + if let Some(outdir) = Path::new(outfile).parent() { fs::create_dir_all(outdir)?; } let mut f = File::create(outfile)?; @@ -130,7 +130,7 @@ mod tests { #[test] fn test_gen_keypair_file() { let outfile = tmp_file_path("test_gen_keypair_file.json"); - let serialized_keypair = gen_keypair_file(outfile.to_string()).unwrap(); + let serialized_keypair = gen_keypair_file(&outfile).unwrap(); let keypair_vec: Vec = serde_json::from_str(&serialized_keypair).unwrap(); assert!(Path::new(&outfile).exists()); assert_eq!( diff --git a/wallet/src/main.rs b/wallet/src/main.rs index 7c99b99d3..1e6f2eb79 100644 --- a/wallet/src/main.rs +++ b/wallet/src/main.rs @@ -37,7 +37,7 @@ pub fn parse_args(matches: &ArgMatches<'_>) -> Result