pub struct Threshold(/* private fields */);Expand description
A proportion between none and all, held as a fraction.
Every threshold this tool takes is one of these: a similarity score to
clear, or a share of duplicated lines to stay under. They differ only in
how they are written – 0.85 in one place, 85.0 in another – so they
are one type with two constructors rather than two types.
The invariant is the point. A similarity threshold of 5 makes the size
pre-filter reject every pair, and the report then says “no near
duplicates” – a silence indistinguishable from a clean codebase. Nothing
downstream can tell that apart, so the value never gets that far.
Implementations§
Source§impl Threshold
impl Threshold
Sourcepub const DEFAULT_SIMILARITY: Self
pub const DEFAULT_SIMILARITY: Self
The similarity threshold used when nothing sets one.
Sourcepub fn fraction(field: &'static str, value: f64) -> Result<Self>
pub fn fraction(field: &'static str, value: f64) -> Result<Self>
A threshold written as a fraction, as similarity_threshold is.
§Errors
Returns Error::InvalidConfig naming field when value is
outside 0.0..=1.0, which NaN also is.
Sourcepub fn percent(field: &'static str, value: f64) -> Result<Self>
pub fn percent(field: &'static str, value: f64) -> Result<Self>
A threshold written as a percentage, as the check ceilings are.
§Errors
Returns Error::InvalidConfig naming field when value is
outside 0.0..=100.0, which NaN also is.
Sourcepub const fn as_fraction(self) -> f64
pub const fn as_fraction(self) -> f64
The threshold as a fraction of one.
Sourcepub fn as_percent(self) -> f64
pub fn as_percent(self) -> f64
The threshold as a share of a hundred.