// Substring contains operation module.
// Backend-specific lowering marker.
// CPU reference kernel for `string_matching.substring_contains`.
use crate::ops::string_matching::search_contract::{validate_search_inputs, MatchError};
/// Return true when `needle` appears in `haystack`.
///
/// # Errors
///
/// Returns `Fix: ...` when either input exceeds the documented T47 cap.
pub fn substring_contains(haystack: &[u8], needle: &[u8]) -> Result<bool, MatchError> {
validate_search_inputs(haystack, needle)?;
if needle.is_empty() {
return Ok(true);
}
Ok(haystack.windows(needle.len()).any(|window| window == needle))
}