criterium 3.1.3

Lightweigt dynamic database queries for rusqlite.
Documentation
// SPDX-FileCopyrightText: 2025 Slatian
//
// SPDX-License-Identifier: LGPL-3.0-only

//! Implements DirectMatch for the BooleanCriterium, doesn't export any functions

use crate::boolean::BooleanCriterium;
use crate::direct_match::DirectMatchResult;
use crate::DirectMatch;

impl DirectMatch<bool> for BooleanCriterium {
	type Output = bool;

	fn criterium_match(&self, data: &bool) -> bool {
		match self {
			Self::Equals(other) => data == other,
			Self::IsNone => false,
		}
	}
}

impl<V> DirectMatch<Option<V>> for BooleanCriterium
where
	BooleanCriterium: DirectMatch<V>,
{
	type Output = <Self as DirectMatch<V>>::Output;

	fn criterium_match(&self, data: &Option<V>) -> Self::Output {
		match &data {
			Some(data) => self.criterium_match(data),
			None => Self::Output::new(matches!(self, Self::IsNone)),
		}
	}
}