use std::{marker::PhantomData, str::FromStr}; #[cfg(feature = "camino")] mod camino; #[cfg(feature = "camino")] pub use camino::Utf8PathFormula; mod boolean; mod numbers; mod path; pub use boolean::{Boolean, BooleanFormula}; pub use numbers::*; pub use path::PathFormula; pub struct Formula { pub(crate) check_fn: Option<(String, Box bool>)>, pub(crate) failure: String, pub(crate) missing: Option, phantom: PhantomData, } impl Formula { pub fn new>(failure: S) -> Self { Self { check_fn: None, failure: failure.into(), missing: None, phantom: PhantomData::default(), } } pub fn check, F>(mut self, fail: S, check: F) -> Self where F: FnMut(&T) -> bool + 'static, { self.check_fn = Some((fail.into(), Box::new(check))); self } pub fn required>(mut self, missing: S) -> Self { self.missing = Some(missing.into()); self } } impl From for Formula { fn from(value: String) -> Self { Formula::new(value) } } impl From<&str> for Formula { fn from(value: &str) -> Self { Formula::new(value) } }