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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! Support items for the `do-notation` feature's [`mdo!`](crate::mdo) macro.
//!
//! This module is compiled only when the non-default `do-notation` feature is
//! enabled. It currently provides [`MdoGuard`], the minimal "monadic zero"
//! helper that backs `guard(..)` statements inside `mdo!` blocks. It is
//! intentionally implemented **only** for instances with a lawful empty element
//! ([`OptionKind`] and [`VecKind`]); using `guard` under any other marker is a
//! deliberate compile error.
use crate;
/// Private module implementing the sealed-trait pattern for [`MdoGuard`].
///
/// The `Sealed` trait is intentionally **not** re-exported, so downstream
/// crates cannot name it and therefore cannot satisfy the `MdoGuard: Sealed`
/// supertrait bound. This restricts `MdoGuard` implementations to the markers
/// sealed here ([`OptionKind`] and [`VecKind`]).
/// Monadic zero used by `guard(..)` inside [`mdo!`](crate::mdo).
///
/// `guard(cond)` desugars to a `bind` over `Self::guard(cond)`: it yields
/// `pure(())` when `cond` is `true` and the instance's lawful zero when `false`,
/// short-circuiting the rest of the block.
///
/// Implemented only for [`OptionKind`] (`None` on `false`) and [`VecKind`]
/// (`vec![]` on `false`) — the two instances with a genuine empty element.
///
/// This trait is **sealed**: it has a private `Sealed` supertrait that only
/// `monadify` can implement, so downstream crates cannot add their own
/// `MdoGuard` instances.