pub struct MetricSet(/* private fields */);Expand description
Bitfield of selected metrics.
Stored on MetricsOptions (controls
which metrics the walker computes) and on
CodeMetrics (controls which fields the
Serialize impl emits).
MetricSet::all() is the default: every metric enabled, matching
the pre-#257 behaviour.
Implementations§
Source§impl MetricSet
impl MetricSet
Sourcepub const fn all() -> Self
pub const fn all() -> Self
Full set (every metric selected). This is the default for
MetricsOptions, preserving the
pre-#257 “compute everything” behaviour.
Sourcepub fn from_slice_with_deps(metrics: &[Metric]) -> Self
pub fn from_slice_with_deps(metrics: &[Metric]) -> Self
Build a MetricSet from a slice, auto-adding the transitive
dependencies of each selected metric.
This is the workhorse behind
MetricsOptions::with_only:
the caller-facing builder enforces the full dependency closure
so a request for Mi alone still computes
Loc + Cyclomatic + Halstead. Exposed pub because
downstream consumers (notably the bca Python bindings’
parse_metric_names helper) parse user input into a
Vec<Metric> and need the same closure-resolution semantics
without re-implementing the worklist.
Implementation note: uses a worklist rather than a single pass
so a future derived metric whose dependency is itself derived
still resolves the complete closure. The loop terminates
because each iteration either inserts a new bit or the
worklist drains; the bitfield is bounded at Metric variant
count.
Sourcepub fn resolved(self) -> Self
pub fn resolved(self) -> Self
Returns this set closed under Metric::dependencies.
Every selected metric’s transitive dependencies are added so a
set carrying a derived metric (e.g. Metric::Mi) also carries
the inputs that metric’s finalize step consumes
(Metric::Loc, Metric::Cyclomatic, Metric::Halstead).
Resolving an already-closed set is a no-op, so the operation is
idempotent: set.resolved().resolved() == set.resolved().
This is the set-in/set-out counterpart of
MetricSet::from_slice_with_deps and is what
MetricsOptions::with_metric_set
applies so a caller-supplied set can never select a derived
metric without its prerequisites (#743).
Implementation note: uses a worklist rather than a single pass
so a future derived metric whose dependency is itself derived
still resolves the complete closure. The loop terminates
because each iteration either inserts a new bit or the worklist
drains; the bitfield is bounded at Metric variant count.
Trait Implementations§
impl Copy for MetricSet
Source§impl Default for MetricSet
impl Default for MetricSet
Source§fn default() -> Self
fn default() -> Self
Default = every metric selected, matching the pre-#257
behaviour of MetricsOptions::default.
impl Eq for MetricSet
impl StructuralPartialEq for MetricSet
Auto Trait Implementations§
impl Freeze for MetricSet
impl RefUnwindSafe for MetricSet
impl Send for MetricSet
impl Sync for MetricSet
impl Unpin for MetricSet
impl UnsafeUnpin for MetricSet
impl UnwindSafe for MetricSet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.