WeightElement

Trait WeightElement 

Source
pub trait WeightElement:
    Clone
    + Default
    + 'static {
    type Sum: NumericSize;

    const IS_UNIT: bool;

    // Required method
    fn to_sum(&self) -> Self::Sum;
}
Expand description

Maps a weight element to its sum/metric type.

This decouples the per-element weight type from the accumulation type. For concrete weights (i32, f64), Sum is the same type. For the unit weight One, Sum = i32.

Required Associated Constants§

Source

const IS_UNIT: bool

Whether this is the unit weight type (One).

Required Associated Types§

Source

type Sum: NumericSize

The numeric type used for sums and comparisons.

Required Methods§

Source

fn to_sum(&self) -> Self::Sum

Convert this weight element to the sum type.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl WeightElement for f64

Source§

const IS_UNIT: bool = false

Source§

type Sum = f64

Source§

fn to_sum(&self) -> f64

Source§

impl WeightElement for i32

Source§

const IS_UNIT: bool = false

Source§

type Sum = i32

Source§

fn to_sum(&self) -> i32

Implementors§