From 80bb3033fd2930d7fa47e92d81871b0125546fa5 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Mon, 5 Oct 2020 16:37:10 +0200 Subject: [PATCH] clippy: fix single_char_pattern Signed-off-by: ljedrz --- compiler/src/console/format.rs | 4 ++-- compiler/src/expression/circuit/circuit.rs | 2 +- leo/commands/add.rs | 2 +- package/src/inputs/pairs.rs | 4 ++-- package/src/root/manifest.rs | 4 ++-- package/src/root/zip.rs | 26 +++++++++++----------- package/src/source/directory.rs | 2 +- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/compiler/src/console/format.rs b/compiler/src/console/format.rs index a379e4cbb4..0d088a93df 100644 --- a/compiler/src/console/format.rs +++ b/compiler/src/console/format.rs @@ -43,10 +43,10 @@ impl> ConstrainedProgram { // Trim starting double quote `"` let mut string = formatted.string.as_str(); - string = string.trim_start_matches("\""); + string = string.trim_start_matches('\"'); // Trim everything after the ending double quote `"` - let parts: Vec<&str> = string.split("\"").collect(); + let parts: Vec<&str> = string.split('\"').collect(); string = parts[0]; // Insert the parameter for each container `{}` diff --git a/compiler/src/expression/circuit/circuit.rs b/compiler/src/expression/circuit/circuit.rs index 8963e7ca22..8e359b890c 100644 --- a/compiler/src/expression/circuit/circuit.rs +++ b/compiler/src/expression/circuit/circuit.rs @@ -40,7 +40,7 @@ impl> ConstrainedProgram { span: Span, ) -> Result, ExpressionError> { // Circuit definitions are located at the minimum file scope - let scopes: Vec<&str> = file_scope.split("_").collect(); + let scopes: Vec<&str> = file_scope.split('_').collect(); let mut program_identifier = new_scope(scopes[0].to_string(), identifier.to_string()); if identifier.is_self() { diff --git a/leo/commands/add.rs b/leo/commands/add.rs index f379ec2840..abf67dffd3 100644 --- a/leo/commands/add.rs +++ b/leo/commands/add.rs @@ -167,7 +167,7 @@ impl CLI for AddCommand { let mut file_path = path.clone(); file_path.push(file_name); - if file_name.ends_with("/") { + if file_name.ends_with('/') { create_dir_all(file_path)?; } else { if let Some(parent_directory) = path.parent() { diff --git a/package/src/inputs/pairs.rs b/package/src/inputs/pairs.rs index c00c8ea908..375bf8fdcc 100644 --- a/package/src/inputs/pairs.rs +++ b/package/src/inputs/pairs.rs @@ -56,7 +56,7 @@ impl TryFrom<&PathBuf> for InputPairs { .to_str() .ok_or(InputsDirectoryError::GettingFileName(file.as_os_str().to_owned()))?; - if file_extension == INPUT_FILE_EXTENSION.trim_start_matches(".") { + if file_extension == INPUT_FILE_EXTENSION.trim_start_matches('.') { let input_file = InputFile::new(file_name).read_from(&file)?.0; if pairs.contains_key(file_name) { @@ -69,7 +69,7 @@ impl TryFrom<&PathBuf> for InputPairs { }; pairs.insert(file_name.to_owned(), pair); } - } else if file_extension == STATE_FILE_EXTENSION.trim_start_matches(".") { + } else if file_extension == STATE_FILE_EXTENSION.trim_start_matches('.') { let state_file = StateFile::new(file_name).read_from(&file)?.0; if pairs.contains_key(file_name) { diff --git a/package/src/root/manifest.rs b/package/src/root/manifest.rs index 485516c06d..de3976ded9 100644 --- a/package/src/root/manifest.rs +++ b/package/src/root/manifest.rs @@ -139,7 +139,7 @@ impl TryFrom<&PathBuf> for Manifest { // Determine if the old remote format is being used if line.starts_with("remote") { let remote = line - .split("=") // Split the line as 'remote' = '"{author}/{package_name}"' + .split('=') // Split the line as 'remote' = '"{author}/{package_name}"' .collect::>()[1]; // Fetch just '"{author}/{package_name}"' old_remote_format = Some(remote); @@ -182,7 +182,7 @@ impl TryFrom<&PathBuf> for Manifest { if !new_remote_format_exists { // Fetch the author from the old remote. let remote_author = old_remote - .split("/") // Split the old remote as '"{author}' and '{package_name}"' + .split('/') // Split the old remote as '"{author}' and '{package_name}"' .collect::>()[0] // Fetch just the '"{author}' .replace(&['\"', ' '][..], ""); // Remove the quotes from the author string diff --git a/package/src/root/zip.rs b/package/src/root/zip.rs index 7277fb3dd6..203f4eb022 100644 --- a/package/src/root/zip.rs +++ b/package/src/root/zip.rs @@ -150,23 +150,23 @@ impl ZipFile { /// Check if the file path should be included in the package zip file. fn is_included(path: &Path) -> bool { // excluded directories: `input`, `output`, `imports` - if path.ends_with(INPUTS_DIRECTORY_NAME.trim_end_matches("/")) - | path.ends_with(OUTPUTS_DIRECTORY_NAME.trim_end_matches("/")) - | path.ends_with(IMPORTS_DIRECTORY_NAME.trim_end_matches("/")) + if path.ends_with(INPUTS_DIRECTORY_NAME.trim_end_matches('/')) + | path.ends_with(OUTPUTS_DIRECTORY_NAME.trim_end_matches('/')) + | path.ends_with(IMPORTS_DIRECTORY_NAME.trim_end_matches('/')) { return false; } // excluded extensions: `.in`, `.bytes`, `lpk`, `lvk`, `.proof`, `.sum`, `.zip`, `.bytes` if let Some(true) = path.extension().map(|ext| { - ext.eq(INPUT_FILE_EXTENSION.trim_start_matches(".")) - | ext.eq(ZIP_FILE_EXTENSION.trim_start_matches(".")) - | ext.eq(PROVING_KEY_FILE_EXTENSION.trim_start_matches(".")) - | ext.eq(VERIFICATION_KEY_FILE_EXTENSION.trim_start_matches(".")) - | ext.eq(PROOF_FILE_EXTENSION.trim_start_matches(".")) - | ext.eq(CHECKSUM_FILE_EXTENSION.trim_start_matches(".")) - | ext.eq(ZIP_FILE_EXTENSION.trim_start_matches(".")) - | ext.eq(CIRCUIT_FILE_EXTENSION.trim_start_matches(".")) + ext.eq(INPUT_FILE_EXTENSION.trim_start_matches('.')) + | ext.eq(ZIP_FILE_EXTENSION.trim_start_matches('.')) + | ext.eq(PROVING_KEY_FILE_EXTENSION.trim_start_matches('.')) + | ext.eq(VERIFICATION_KEY_FILE_EXTENSION.trim_start_matches('.')) + | ext.eq(PROOF_FILE_EXTENSION.trim_start_matches('.')) + | ext.eq(CHECKSUM_FILE_EXTENSION.trim_start_matches('.')) + | ext.eq(ZIP_FILE_EXTENSION.trim_start_matches('.')) + | ext.eq(CIRCUIT_FILE_EXTENSION.trim_start_matches('.')) }) { return false; } @@ -177,12 +177,12 @@ fn is_included(path: &Path) -> bool { } // Only allow additional files in the `src/` directory - if !path.starts_with(SOURCE_DIRECTORY_NAME.trim_end_matches("/")) { + if !path.starts_with(SOURCE_DIRECTORY_NAME.trim_end_matches('/')) { return false; } // Allow the `.leo` files in the `src/` directory path.extension() - .map(|ext| ext.eq(SOURCE_FILE_EXTENSION.trim_start_matches("."))) + .map(|ext| ext.eq(SOURCE_FILE_EXTENSION.trim_start_matches('.'))) .unwrap_or(false) } diff --git a/package/src/source/directory.rs b/package/src/source/directory.rs index 083a1bc935..1081ad3ee8 100644 --- a/package/src/source/directory.rs +++ b/package/src/source/directory.rs @@ -61,7 +61,7 @@ impl SourceDirectory { let file_extension = file_path .extension() .ok_or_else(|| SourceDirectoryError::GettingFileExtension(file_path.as_os_str().to_owned()))?; - if file_extension != SOURCE_FILE_EXTENSION.trim_start_matches(".") { + if file_extension != SOURCE_FILE_EXTENSION.trim_start_matches('.') { return Err(SourceDirectoryError::InvalidFileExtension( file_path.as_os_str().to_owned(), file_extension.to_owned(),