summaryrefslogtreecommitdiff
path: root/chain/src/default.rs
blob: e04be9fcf53952d55a8f94e5bed66607002a4726 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//! This file provides a default implementation of the
//! [`Chain`][crate::Chain] trait.
//!
//! The reason for using a trait is that I might want to experiment
//! with different implementation ideas in the future, and this
//! modular design makes that easy.

use super::*;
use core::fmt::Display;

/// The errors related to taking derivatives by chain rule.
#[derive(Debug)]
pub enum Error {
    /// An invalid situation happens.
    Invalid,
}

impl Display for Error {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::Invalid => write!(f, "invalid"),
        }
    }
}

impl std::error::Error for Error {}

/// A default implementation for the [`Chain`] trait.
#[derive(Debug, Clone, Default)]
pub struct DefaultChain {}

impl Chain for DefaultChain {
    type Error = Error;

    fn unit() -> Self {
        todo!()
    }

    fn chain(&mut self, _t: usize) {
        todo!()
    }

    fn epsilon(&self) -> bool {
        todo!()
    }
}