scopegraphs_lib/completeness/
unchecked.rs

1use crate::{completeness::private::Sealed, completeness::Completeness, InnerScopeGraph, Scope};
2use std::hash::Hash;
3
4/// No-Op implementation of [`Completeness`].
5#[derive(Debug)]
6pub struct UncheckedCompleteness {}
7
8impl Sealed for UncheckedCompleteness {}
9
10impl UncheckedCompleteness {
11    /// Constructs a new instance of [`UncheckedCompleteness`].
12    ///
13    /// # Safety
14    ///
15    /// Marked as `unsafe`, as it does adhere to its contract (guaranteeing stability).
16    ///
17    /// Unless you are sure you really need this, consider alternatives
18    /// such as [`ImplicitClose`] or [`ExplicitClose`].
19    pub unsafe fn new() -> Self {
20        Self {}
21    }
22}
23
24impl<LABEL: Hash + Eq, DATA> Completeness<LABEL, DATA> for UncheckedCompleteness {
25    fn cmpl_new_scope(&self, _: &InnerScopeGraph<LABEL, DATA>, _: Scope) {}
26
27    type NewEdgeResult = ();
28
29    fn cmpl_new_edge(
30        &self,
31        inner_scope_graph: &InnerScopeGraph<LABEL, DATA>,
32        src: Scope,
33        lbl: LABEL,
34        dst: Scope,
35    ) -> Self::NewEdgeResult {
36        inner_scope_graph.add_edge(src, lbl, dst)
37    }
38
39    type GetEdgesResult<'rslv> = Vec<Scope>
40        where
41            Self: 'rslv, LABEL: 'rslv, DATA: 'rslv;
42
43    fn cmpl_get_edges<'rslv>(
44        &self,
45        inner_scope_graph: &InnerScopeGraph<LABEL, DATA>,
46        src: Scope,
47        lbl: LABEL,
48    ) -> Self::GetEdgesResult<'rslv>
49    where
50        LABEL: 'rslv,
51        DATA: 'rslv,
52    {
53        inner_scope_graph.get_edges(src, lbl)
54    }
55}