Skip to main content

oxilean_std/decidable/
fnpred_traits.rs

1//! # FnPred - Trait Implementations
2//!
3//! This module contains trait implementations for `FnPred`.
4//!
5//! ## Implemented Traits
6//!
7//! - `DecidablePred`
8//!
9//! 🤖 Generated with [SplitRS](https://github.com/cool-japan/splitrs)
10
11use super::functions::DecidablePred;
12use super::types::{Decision, FnPred};
13
14impl<A, F: Fn(&A) -> bool> DecidablePred<A> for FnPred<A, F> {
15    fn decide_pred(&self, a: &A) -> Decision<()> {
16        if (self.0)(a) {
17            Decision::IsTrue(())
18        } else {
19            Decision::IsFalse("predicate returned false".to_string())
20        }
21    }
22}