From f564a322292930850767f1ad1d39e882e38c8368 Mon Sep 17 00:00:00 2001 From: dromaz Date: Mon, 17 Jul 2023 00:23:09 +0200 Subject: [PATCH] avm: add .anchorversion file & rustfmt lib.rs file --- avm/src/lib.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/avm/src/lib.rs b/avm/src/lib.rs index 122bd3f034..88a572e3dd 100644 --- a/avm/src/lib.rs +++ b/avm/src/lib.rs @@ -48,7 +48,7 @@ pub fn version_binary_path(version: &Version) -> PathBuf { pub fn use_version(opt_version: Option) -> Result<()> { let version = match opt_version { Some(version) => version, - None => read_anchorversion_file()? + None => read_anchorversion_file()?, }; let installed_versions = read_installed_versions(); @@ -142,10 +142,10 @@ pub fn uninstall_version(version: &Version) -> Result<()> { /// Read version from .anchorversion pub fn read_anchorversion_file() -> Result { fs::read_to_string(".anchorversion") - .map_err(|e| anyhow!(".anchorversion file not found: {e}")) - .map(|content| Version::parse(content.trim()))? - .map_err(|e| anyhow!("Unable to parse version: {e}")) -} + .map_err(|e| anyhow!(".anchorversion file not found: {e}")) + .map(|content| Version::parse(content.trim()))? + .map_err(|e| anyhow!("Unable to parse version: {e}")) +} /// Ensure the users home directory is setup with the paths required by AVM. pub fn ensure_paths() { @@ -250,9 +250,9 @@ pub fn read_installed_versions() -> Vec { mod tests { use crate::*; use semver::Version; + use std::env; use std::fs; use std::io::Write; - use std::env; #[test] fn test_read_anchorversion() { @@ -263,12 +263,11 @@ mod tests { let test_version = "0.26.0"; file_created.write(test_version.as_bytes()).unwrap(); - let version = read_anchorversion_file(); match version { Ok(v) => { assert_eq!(v.to_string(), test_version); - }, + } Err(_e) => { assert!(false); }