scopegraphs/completeness/
unchecked.rs

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