IterState

Trait IterState 

Source
pub trait IterState: Sized {
    type Value;
    type Solution;

    // Required methods
    fn init_from_value(initial_point: Self::Value) -> Self;
    fn to_sol(&self) -> Self::Solution;
}
Expand description

Intermediate state of an iterative algorithm.

For many iterative algorithms, the intermediate state often requires a more complex structure to describe compared to the initial iteration value and the solution.

In practical iterative algorithms, it is often necessary to perform some simple computations or obtain algorithm metadata after obtaining the solution.

Therefore, IterState allows you to customize the intermediate state and separate the abstractions of value and solution.

If you expect the simplest behavior, this crate has already implemented IterState for basic data types i*, u*, and f*, where their associated types Value and Solution are themselves.

Required Associated Types§

Source

type Value

Type representing the value during iteration (e.g., intermediate computation results).

Source

type Solution

Type representing the final solution.

Required Methods§

Source

fn init_from_value(initial_point: Self::Value) -> Self

Initializes the state from an initial value.

Source

fn to_sol(&self) -> Self::Solution

Converts the current state into the solution.

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

Source§

type Value = f32

Source§

type Solution = f32

Source§

fn init_from_value(initial_point: Self::Value) -> Self

Source§

fn to_sol(&self) -> Self::Solution

Source§

impl IterState for f64

Source§

type Value = f64

Source§

type Solution = f64

Source§

fn init_from_value(initial_point: Self::Value) -> Self

Source§

fn to_sol(&self) -> Self::Solution

Source§

impl IterState for i8

Source§

type Value = i8

Source§

type Solution = i8

Source§

fn init_from_value(initial_point: Self::Value) -> Self

Source§

fn to_sol(&self) -> Self::Solution

Source§

impl IterState for i16

Source§

type Value = i16

Source§

type Solution = i16

Source§

fn init_from_value(initial_point: Self::Value) -> Self

Source§

fn to_sol(&self) -> Self::Solution

Source§

impl IterState for i32

Source§

type Value = i32

Source§

type Solution = i32

Source§

fn init_from_value(initial_point: Self::Value) -> Self

Source§

fn to_sol(&self) -> Self::Solution

Source§

impl IterState for i64

Source§

type Value = i64

Source§

type Solution = i64

Source§

fn init_from_value(initial_point: Self::Value) -> Self

Source§

fn to_sol(&self) -> Self::Solution

Source§

impl IterState for i128

Source§

type Value = i128

Source§

type Solution = i128

Source§

fn init_from_value(initial_point: Self::Value) -> Self

Source§

fn to_sol(&self) -> Self::Solution

Source§

impl IterState for isize

Source§

type Value = isize

Source§

type Solution = isize

Source§

fn init_from_value(initial_point: Self::Value) -> Self

Source§

fn to_sol(&self) -> Self::Solution

Source§

impl IterState for u8

Source§

type Value = u8

Source§

type Solution = u8

Source§

fn init_from_value(initial_point: Self::Value) -> Self

Source§

fn to_sol(&self) -> Self::Solution

Source§

impl IterState for u16

Source§

type Value = u16

Source§

type Solution = u16

Source§

fn init_from_value(initial_point: Self::Value) -> Self

Source§

fn to_sol(&self) -> Self::Solution

Source§

impl IterState for u32

Source§

type Value = u32

Source§

type Solution = u32

Source§

fn init_from_value(initial_point: Self::Value) -> Self

Source§

fn to_sol(&self) -> Self::Solution

Source§

impl IterState for u64

Source§

type Value = u64

Source§

type Solution = u64

Source§

fn init_from_value(initial_point: Self::Value) -> Self

Source§

fn to_sol(&self) -> Self::Solution

Source§

impl IterState for u128

Source§

type Value = u128

Source§

type Solution = u128

Source§

fn init_from_value(initial_point: Self::Value) -> Self

Source§

fn to_sol(&self) -> Self::Solution

Source§

impl IterState for usize

Source§

type Value = usize

Source§

type Solution = usize

Source§

fn init_from_value(initial_point: Self::Value) -> Self

Source§

fn to_sol(&self) -> Self::Solution

Implementors§