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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//! Store mutation primitives without contract validation.
use ;
use crate::;
/// Minimal endpoint update of a live link, without contract validation.
///
/// Implemented by both memory stores. Their safe [`Links::update_links`] and
/// [`Links::delete_links`] methods are checked convenience routes: they
/// delegate to [`CheckedMutation`], which rejects a missing address with
/// [`Error::NotExists`] before calling these primitives. A caller that already
/// guarantees the preconditions below can call the primitives directly and
/// skip that redundant verification.
///
/// Deletion is composed from two primitives: an optional endpoint reset via
/// [`update_unchecked`](Self::update_unchecked) to `(0, 0)`, followed by
/// [`Release::release_unchecked`]. Resetting is a policy, not part of
/// release, so the caller decides whether it is needed.
///
/// See `docs/mutation.md` for the full contract and the checked, ignore-missing
/// and unchecked routes.
///
/// # Examples
///
/// ```
/// use doublets::{
/// mem::{Global, Release, UncheckedMutation},
/// unit, Doublets,
/// };
/// use data::Flow;
/// # fn main() -> Result<(), doublets::Error<u32>> {
/// let mut store = unit::Store::<u32, _>::new(Global::new())?;
/// let a = store.create_point()?;
/// let b = store.create()?;
///
/// // SAFETY: `b` was just created by this store and is still live.
/// unsafe { store.update_unchecked(b, a, b, &mut |_, _| Flow::Continue) };
/// assert_eq!(store.search(a, b), Some(b));
///
/// // SAFETY: `b` is live; resetting it detaches its outgoing index memberships,
/// // which is the remaining precondition of `release_unchecked`.
/// unsafe {
/// store.update_unchecked(b, 0, 0, &mut |_, _| Flow::Continue);
/// store.release_unchecked(b, &mut |_, _| Flow::Continue);
/// }
/// assert!(!store.exist(b));
/// # Ok(())
/// # }
/// ```
///
/// [`Links::update_links`]: crate::Links::update_links
/// [`Links::delete_links`]: crate::Links::delete_links
/// [`CheckedMutation`]: crate::decorators::CheckedMutation
/// [`Error::NotExists`]: crate::Error::NotExists