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
use fmt;
/// The Apache TinkerPop `Pop` token: which occurrence of a repeated step label `select` reads.
///
/// A label occurs several times on a path when `as("a")` sits inside `repeat()` or is set at
/// several steps. `select("a")` reads the newest occurrence (`Pop::Last`); the other pops choose
/// differently (`select(Pop.first, "a")` in the Rhai DSL, [`select_pop`](crate::GraphTraversalSource::select_pop)
/// in Rust):
///
/// - [`First`](Pop::First): the oldest occurrence (path order).
/// - [`Last`](Pop::Last): the newest occurrence; the default and what `select("a")` does.
/// - [`All`](Pop::All): a list of every occurrence in path order, always a list (one occurrence
/// gives a one-element list). A label on no position of the path filters the traverser.
/// - [`Mixed`](Pop::Mixed): the occurrence itself when the label occurs once, a list in path
/// order when it occurs several times.
///
/// Several labels on one position (`as("a").as("a")`) are one occurrence. `Pop` applies only to a
/// label read from the path: a key of the traverser's own map and a side-effect key win over the
/// path and ignore the pop. See `book/src/users_guide/select_pop.md` for the semantics and the
/// verified TinkerPop sources.
///
/// ```rust
/// use graphersal::prelude::*;
///
/// let graph = GraphSource::tinkerpop_modern();
/// let lock = graph.read();
/// let names = lock
/// .traversal()
/// .v("1")
/// .as_("a")
/// .repeat(__::out(None).as_("a"))
/// .times(2)
/// .select_pop(Pop::All, "a")
/// .to_list()
/// .unwrap();
/// assert_eq!(names.len(), 2);
/// assert_eq!(Pop::default(), Pop::Last);
/// ```
///
/// Closed set, so deliberately not `#[non_exhaustive]` (rule 15): TinkerPop has defined exactly
/// these four members since 3.0, as for [`Scope`](crate::Scope).