1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use crate::;
/// An item that can appear at the top level of a detector error model.
///
/// A [`DetectorErrorModel`](crate::DetectorErrorModel) is a sequence of
/// `DemItem`s. Each item is one of:
///
/// - [`Instruction`](Self::Instruction) -- a single DEM instruction such
/// as `error(0.125) D0 D1`, `detector(1.5, 2.0) D3`, or
/// `shift_detectors 1`.
/// - [`RepeatBlock`](Self::RepeatBlock) -- a `repeat N { ... }` construct
/// containing a sub-model that is repeated `N` times.
///
/// This enum is the DEM analog of
/// [`CircuitItem`](crate::CircuitItem), which plays the same role for
/// circuit instructions. You can iterate over the items of a
/// `DetectorErrorModel` to inspect or transform its contents.
///
/// # Examples
///
/// ```
/// let inst: stim::DemInstruction = "error(0.125) D0 D1".parse().expect("valid");
/// let item = stim::DemItem::Instruction(inst.clone());
/// assert_eq!(item, stim::DemItem::Instruction(inst));
///
/// let body: stim::DetectorErrorModel = "error(0.1) D0".parse().expect("valid");
/// let block = stim::DemRepeatBlock::new(10, &body).expect("valid");
/// let item = stim::DemItem::RepeatBlock(block.clone());
/// assert_eq!(item, stim::DemItem::RepeatBlock(block));
/// ```