//! 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!() } }