apply clippy suggestions
This commit is contained in:
parent
f41c2eb66b
commit
958466818b
12 changed files with 38 additions and 41 deletions
|
@ -24,7 +24,7 @@ pub fn to_animal_names(mut number: u64) -> String {
|
|||
number -= digit * ANIMAL_NAMES.len().pow(power) as u64;
|
||||
if power > 0 {
|
||||
power -= 1;
|
||||
} else if power <= 0 || number == 0 {
|
||||
} else if power == 0 || number == 0 {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -35,12 +35,12 @@ pub fn to_animal_names(mut number: u64) -> String {
|
|||
pub fn to_u64(animal_names: &str) -> Result<u64, &str> {
|
||||
let mut result: u64 = 0;
|
||||
|
||||
let animals: Vec<&str> = animal_names.split("-").collect();
|
||||
let animals: Vec<&str> = animal_names.split('-').collect();
|
||||
|
||||
let mut pow = animals.len();
|
||||
for i in 0..animals.len() {
|
||||
for animal in animals {
|
||||
pow -= 1;
|
||||
let animal_index = ANIMAL_NAMES.iter().position(|&r| r == animals[i]);
|
||||
let animal_index = ANIMAL_NAMES.iter().position(|&r| r == animal);
|
||||
match animal_index {
|
||||
None => return Err("Failed to convert animal name to u64!"),
|
||||
Some(_) => {
|
||||
|
|
|
@ -4,7 +4,7 @@ use std::io::{BufReader, BufWriter};
|
|||
|
||||
use crate::Pasta;
|
||||
|
||||
static DATABASE_PATH: &'static str = "pasta_data/database.json";
|
||||
static DATABASE_PATH: &str = "pasta_data/database.json";
|
||||
|
||||
pub fn save_to_file(pasta_data: &Vec<Pasta>) {
|
||||
let mut file = File::create(DATABASE_PATH);
|
||||
|
|
|
@ -13,6 +13,6 @@ pub fn to_u64(hash_id: &str) -> Result<u64, &str> {
|
|||
let ids = HARSH
|
||||
.decode(hash_id)
|
||||
.map_err(|_e| "Failed to decode hash ID")?;
|
||||
let id = ids.get(0).ok_or("No ID found in hash ID")?;
|
||||
let id = ids.first().ok_or("No ID found in hash ID")?;
|
||||
Ok(*id)
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ pub fn html_highlight(text: &str, extension: &str) -> String {
|
|||
|
||||
let syntax = ps
|
||||
.find_syntax_by_extension(extension)
|
||||
.or(Option::from(ps.find_syntax_plain_text()))
|
||||
.or_else(|| Option::from(ps.find_syntax_plain_text()))
|
||||
.unwrap();
|
||||
let mut h = HighlightLines::new(syntax, &ts.themes["InspiredGitHub"]);
|
||||
|
||||
|
@ -33,5 +33,5 @@ pub fn html_highlight(text: &str, extension: &str) -> String {
|
|||
highlighted_content2 =
|
||||
highlighted_content2.replace("style=\"color:#183691;\"", "style=\"color:blue;\"");
|
||||
|
||||
return highlighted_content2;
|
||||
highlighted_content2
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue