From 520f30de56df045008ea5fd9f33f7293937b12e5 Mon Sep 17 00:00:00 2001 From: Predrag Gruevski Date: Fri, 31 Mar 2023 00:01:30 +0000 Subject: [PATCH] Seal the VertexInfo and InternalVertexInfo traits. --- trustfall_core/src/interpreter/hints/mod.rs | 4 ++++ trustfall_core/src/interpreter/hints/sealed.rs | 1 + trustfall_core/src/interpreter/hints/vertex_info.rs | 6 +++--- 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 trustfall_core/src/interpreter/hints/sealed.rs diff --git a/trustfall_core/src/interpreter/hints/mod.rs b/trustfall_core/src/interpreter/hints/mod.rs index aa25e88e..e621be0e 100644 --- a/trustfall_core/src/interpreter/hints/mod.rs +++ b/trustfall_core/src/interpreter/hints/mod.rs @@ -9,6 +9,7 @@ use crate::ir::{ }; mod candidates; +mod sealed; mod vertex_info; pub use candidates::CandidateValue; @@ -75,6 +76,9 @@ impl ResolveInfo { } } +impl sealed::__Sealed for ResolveInfo {} +impl sealed::__Sealed for NeighborInfo {} + impl InternalVertexInfo for ResolveInfo { #[inline] fn current_vertex(&self) -> &IRVertex { diff --git a/trustfall_core/src/interpreter/hints/sealed.rs b/trustfall_core/src/interpreter/hints/sealed.rs new file mode 100644 index 00000000..836b393d --- /dev/null +++ b/trustfall_core/src/interpreter/hints/sealed.rs @@ -0,0 +1 @@ +pub trait __Sealed {} diff --git a/trustfall_core/src/interpreter/hints/vertex_info.rs b/trustfall_core/src/interpreter/hints/vertex_info.rs index eba9c74e..0cc8b688 100644 --- a/trustfall_core/src/interpreter/hints/vertex_info.rs +++ b/trustfall_core/src/interpreter/hints/vertex_info.rs @@ -6,7 +6,7 @@ use super::EdgeInfo; /// Information about what the currently-executing query needs at a specific vertex. #[cfg_attr(docsrs, doc(notable_trait))] -pub trait VertexInfo { +pub trait VertexInfo: super::sealed::__Sealed { /// The unique ID of the vertex this [`VertexInfo`] describes. fn vid(&self) -> Vid; @@ -38,7 +38,7 @@ pub trait VertexInfo { fn edges_with_name<'a>(&'a self, name: &'a str) -> Box + 'a>; } -pub(super) trait InternalVertexInfo { +pub(super) trait InternalVertexInfo: super::sealed::__Sealed { fn current_vertex(&self) -> &IRVertex; fn current_component(&self) -> &IRQueryComponent; @@ -48,7 +48,7 @@ pub(super) trait InternalVertexInfo { fn make_folded_edge_info(&self, fold: &IRFold) -> EdgeInfo; } -impl VertexInfo for T { +impl VertexInfo for T { fn vid(&self) -> Vid { self.current_vertex().vid }