Trait Cost

Source
pub trait Cost {
    // Required methods
    fn identity() -> Self;
    fn unit() -> Self;
    fn combine(self, other: &Self) -> Self;
}
Expand description

Requirements for a type to be usable as a cost by a CostModel.

Required Methods§

Source

fn identity() -> Self

An identity element, usually zero.

Source

fn unit() -> Self

The default cost for a node with no children, usually one.

Source

fn combine(self, other: &Self) -> Self

A binary operation to combine costs, usually addition. This operation must NOT overflow or panic when given large values!

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 Cost for f32

Source§

fn identity() -> Self

Source§

fn unit() -> Self

Source§

fn combine(self, other: &Self) -> Self

Source§

impl Cost for f64

Source§

fn identity() -> Self

Source§

fn unit() -> Self

Source§

fn combine(self, other: &Self) -> Self

Source§

impl Cost for i8

Source§

fn identity() -> Self

Source§

fn unit() -> Self

Source§

fn combine(self, other: &Self) -> Self

Source§

impl Cost for i16

Source§

fn identity() -> Self

Source§

fn unit() -> Self

Source§

fn combine(self, other: &Self) -> Self

Source§

impl Cost for i32

Source§

fn identity() -> Self

Source§

fn unit() -> Self

Source§

fn combine(self, other: &Self) -> Self

Source§

impl Cost for i64

Source§

fn identity() -> Self

Source§

fn unit() -> Self

Source§

fn combine(self, other: &Self) -> Self

Source§

impl Cost for i128

Source§

fn identity() -> Self

Source§

fn unit() -> Self

Source§

fn combine(self, other: &Self) -> Self

Source§

impl Cost for isize

Source§

fn identity() -> Self

Source§

fn unit() -> Self

Source§

fn combine(self, other: &Self) -> Self

Source§

impl Cost for u8

Source§

fn identity() -> Self

Source§

fn unit() -> Self

Source§

fn combine(self, other: &Self) -> Self

Source§

impl Cost for u16

Source§

fn identity() -> Self

Source§

fn unit() -> Self

Source§

fn combine(self, other: &Self) -> Self

Source§

impl Cost for u32

Source§

fn identity() -> Self

Source§

fn unit() -> Self

Source§

fn combine(self, other: &Self) -> Self

Source§

impl Cost for u64

Source§

fn identity() -> Self

Source§

fn unit() -> Self

Source§

fn combine(self, other: &Self) -> Self

Source§

impl Cost for u128

Source§

fn identity() -> Self

Source§

fn unit() -> Self

Source§

fn combine(self, other: &Self) -> Self

Source§

impl Cost for usize

Source§

fn identity() -> Self

Source§

fn unit() -> Self

Source§

fn combine(self, other: &Self) -> Self

Source§

impl Cost for BigInt

Source§

fn identity() -> Self

Source§

fn unit() -> Self

Source§

fn combine(self, other: &Self) -> Self

Source§

impl Cost for BigRational

Source§

fn identity() -> Self

Source§

fn unit() -> Self

Source§

fn combine(self, other: &Self) -> Self

Implementors§