Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Zheoni committed Aug 12, 2024
1 parent a7a90f8 commit 08a0c2d
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
5 changes: 1 addition & 4 deletions src/analysis/event_consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1251,10 +1251,7 @@ impl RefComponent for Cookware<ScalableValue> {
}

fn find_temperature<'a>(text: &'a str, re: &Regex) -> Option<(&'a str, Quantity<Value>, &'a str)> {
let Some(caps) = re.captures(text) else {
return None;
};

let caps = re.captures(text)?;
let value = caps[1].replace(',', ".").parse::<f64>().ok()?;
let unit = caps.get(3).unwrap().range();
let unit_text = text[unit].to_string();
Expand Down
2 changes: 1 addition & 1 deletion src/convert/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ pub struct Unit {
pub ratio: f64,
/// Difference offset to the conversion ratio
pub difference: f64,
/// The [PhysicalQuantity] this unit belongs to
/// The [`PhysicalQuantity`] this unit belongs to
pub physical_quantity: PhysicalQuantity,
/// The unit [System] this unit belongs to, if any
pub system: Option<System>,
Expand Down
2 changes: 1 addition & 1 deletion src/ingredient_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ impl IntoIterator for IngredientList {
pub struct CategorizedIngredientList {
/// One ingredient list per category
///
/// Because this is a [BTreeMap], the categories are sorted by name
/// Because this is a [`BTreeMap`], the categories are sorted by name
pub categories: BTreeMap<String, IngredientList>,
/// Ingredients with no category assigned
pub other: IngredientList,
Expand Down
2 changes: 1 addition & 1 deletion src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ impl NameAndUrl {
fn new(name: Option<&str>, url: Option<Url>) -> Self {
let name = name
.map(|n| n.trim())
.filter(|n| n.len() > 0)
.filter(|n| !n.is_empty())
.map(String::from);
Self { name, url }
}
Expand Down
6 changes: 5 additions & 1 deletion src/quantity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,11 @@ impl FractionLookupTable {
const DENOMS: &'static [u8] = &[2, 3, 4, 8, 10, 16];

pub fn new() -> Self {
debug_assert!(!Self::DENOMS.is_empty());
#[allow(clippy::const_is_empty)]
{
// I really want to be sure clippy
debug_assert!(!Self::DENOMS.is_empty());
}
debug_assert!(Self::DENOMS.windows(2).all(|w| w[0] < w[1]));
let mut table = Vec::new();

Expand Down

0 comments on commit 08a0c2d

Please sign in to comment.