Skip to main content

MetricSet

Struct MetricSet 

Source
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

Source

pub const fn empty() -> Self

Empty set (no metrics selected).

Source

pub const fn all() -> Self

Full set (every metric selected). This is the default for MetricsOptions, preserving the pre-#257 “compute everything” behaviour.

Source

pub const fn contains(self, metric: Metric) -> bool

Returns true if metric is in the set.

Source

pub const fn with(self, metric: Metric) -> Self

Returns a new set with metric inserted.

Source

pub const fn union(self, other: Self) -> Self

Returns the union of two sets.

Source

pub fn insert(&mut self, metric: Metric)

Insert metric (in place).

Source

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.

Trait Implementations§

Source§

impl Clone for MetricSet

Source§

fn clone(&self) -> MetricSet

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MetricSet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MetricSet

Source§

fn default() -> Self

Default = every metric selected, matching the pre-#257 behaviour of MetricsOptions::default.

Source§

impl Hash for MetricSet

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for MetricSet

Source§

fn eq(&self, other: &MetricSet) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for MetricSet

Source§

impl Eq for MetricSet

Source§

impl StructuralPartialEq for MetricSet

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.