Skip to main content

oxilean_elab/instance/
instanceerror_traits.rs

1//! # InstanceError - Trait Implementations
2//!
3//! This module contains trait implementations for `InstanceError`.
4//!
5//! ## Implemented Traits
6//!
7//! - `Display`
8//!
9//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)
10
11use super::types::InstanceError;
12use std::fmt;
13
14impl std::fmt::Display for InstanceError {
15    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
16        match self {
17            InstanceError::NotFound { class } => {
18                write!(f, "no instance for class '{:?}'", class)
19            }
20            InstanceError::Ambiguous { class, candidates } => {
21                write!(
22                    f,
23                    "ambiguous instances for class '{:?}': {:?}",
24                    class, candidates
25                )
26            }
27            InstanceError::MaxDepthExceeded { depth } => {
28                write!(f, "instance search exceeded max depth {}", depth)
29            }
30            InstanceError::CircularDependency { chain } => {
31                write!(f, "circular instance dependency: {:?}", chain)
32            }
33            InstanceError::UnresolvableSubgoal { instance, subgoal } => {
34                write!(
35                    f,
36                    "instance '{}' has unresolvable subgoal '{}'",
37                    instance, subgoal
38                )
39            }
40        }
41    }
42}