luaur_analysis/records/arcs.rs
1//! Faithful port of `Luau::detail::Arcs` (`Analysis/src/TopoSortStatements.cpp:72`).
2//!
3//! ```cpp
4//! struct Arcs
5//! {
6//! std::set<Node*> provides;
7//! std::set<Node*> depends;
8//! };
9//! ```
10//!
11//! `std::set<Node*>` is an ordered set keyed by the raw node pointer; the C++
12//! code relies only on insert / erase / find / empty, all of which a Rust
13//! `BTreeSet<*mut Node>` provides with identical semantics (raw pointers have a
14//! total `Ord`).
15
16use crate::records::node::Node;
17use alloc::collections::BTreeSet;
18
19#[derive(Debug, Clone, Default)]
20pub struct Arcs {
21 pub(crate) provides: BTreeSet<*mut Node>,
22 pub(crate) depends: BTreeSet<*mut Node>,
23}
24
25impl Arcs {
26 pub fn new() -> Self {
27 Self {
28 provides: BTreeSet::new(),
29 depends: BTreeSet::new(),
30 }
31 }
32}