Skip to main content

ppvm_pauli_word/pattern/
trace.rs

1// SPDX-FileCopyrightText: 2026 The PPVM Authors
2// SPDX-License-Identifier: Apache-2.0
3
4use super::contains::Contains;
5use super::data::PauliPattern;
6
7use crate::loss::LossyPauliWord;
8use crate::word::PauliWord;
9use ppvm_traits::traits::{HashFinalize, PauliStorage, PauliWordTrait, Trace};
10use std::hash::BuildHasher;
11
12impl<'a, A, H> Trace<'a, PauliPattern> for PauliWord<A, H>
13where
14    A: PauliStorage + 'a,
15    H: Default + BuildHasher + Clone + HashFinalize + 'a,
16{
17    type Output = bool;
18    fn trace(&'a self, value: &'a PauliPattern) -> Self::Output {
19        value.contains(&self)
20    }
21}
22
23impl<'a, A, H> Trace<'a, PauliPattern> for LossyPauliWord<A, H>
24where
25    A: PauliStorage + 'a,
26    H: Default + BuildHasher + Clone + HashFinalize + 'a,
27{
28    type Output = bool;
29    fn trace(&'a self, value: &'a PauliPattern) -> Self::Output {
30        value.contains(&self)
31    }
32}
33
34impl<'a, W> Trace<'a, W> for PauliPattern
35where
36    W: PauliWordTrait + 'a,
37{
38    type Output = bool;
39    fn trace(&'a self, value: &'a W) -> Self::Output {
40        self.contains(value)
41    }
42}