clippy: fix single_char_pattern

Signed-off-by: ljedrz <ljedrz@gmail.com>
This commit is contained in:
ljedrz 2020-10-05 16:37:10 +02:00
parent c21b5ad2f3
commit 80bb3033fd
7 changed files with 22 additions and 22 deletions

View File

@ -43,10 +43,10 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
// 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 `{}`

View File

@ -40,7 +40,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
span: Span,
) -> Result<ConstrainedValue<F, G>, 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() {

View File

@ -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() {

View File

@ -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) {

View File

@ -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::<Vec<&str>>()[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::<Vec<&str>>()[0] // Fetch just the '"{author}'
.replace(&['\"', ' '][..], ""); // Remove the quotes from the author string

View File

@ -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)
}

View File

@ -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(),