From 12db26c34fabb99e76187d1ce538324a0b63ff10 Mon Sep 17 00:00:00 2001 From: Marvin Hansen Date: Thu, 25 Jan 2024 12:21:59 +0800 Subject: [PATCH] Narrowed down overly general type constrains on generic type parameters. Signed-off-by: Marvin Hansen --- .../src/protocols/contextuable/mod.rs | 41 +++++++++++++-- .../src/protocols/contextuable_graph/mod.rs | 21 +++++++- .../context_graph/contextuable_graph.rs | 10 +++- .../context_types/context_graph/debug.rs | 31 +++++++++-- .../extendable_contextuable_graph.rs | 20 +++++++- .../context_graph/identifiable.rs | 11 +++- .../context_types/context_graph/indexable.rs | 11 +++- .../types/context_types/context_graph/mod.rs | 21 +++++++- .../contextoid/contextoid_type.rs | 32 ++++++++++-- .../context_types/contextoid/contextuable.rs | 11 +++- .../types/context_types/contextoid/display.rs | 12 ++++- .../context_types/contextoid/identifiable.rs | 11 +++- .../src/types/context_types/contextoid/mod.rs | 21 +++++++- .../context_types/node_types/data/display.rs | 3 +- .../node_types/data/identifiable.rs | 4 +- .../context_types/node_types/data/mod.rs | 6 ++- .../context_types/node_types/space/display.rs | 12 ++++- .../node_types/space/identifiable.rs | 11 +++- .../context_types/node_types/space/mod.rs | 11 +++- .../context_types/node_types/space/spatial.rs | 11 +++- .../node_types/space_time/display.rs | 12 ++++- .../node_types/space_time/identifiable.rs | 11 +++- .../node_types/space_time/mod.rs | 11 +++- .../node_types/space_time/space_temporal.rs | 11 +++- .../node_types/space_time/spatial.rs | 11 +++- .../node_types/space_time/temporable.rs | 11 +++- .../context_types/node_types/time/display.rs | 12 ++++- .../node_types/time/identifiable.rs | 11 +++- .../context_types/node_types/time/mod.rs | 11 +++- .../node_types/time/temporable.rs | 11 +++- .../adjustable_data/adjustable.rs | 3 ++ .../adjustable_data/display.rs | 2 +- .../adjustable_data/identifiable.rs | 2 +- .../adjustable_data/mod.rs | 6 ++- .../adjustable_space/adjustable.rs | 3 ++ .../adjustable_space/display.rs | 11 +++- .../adjustable_space/identifiable.rs | 10 +++- .../adjustable_space/mod.rs | 11 +++- .../adjustable_space/spatial.rs | 10 +++- .../adjustable_space_time/adjustable.rs | 8 ++- .../adjustable_space_time/display.rs | 14 ++++- .../adjustable_space_time/identifiable.rs | 10 +++- .../adjustable_space_time/mod.rs | 11 +++- .../adjustable_space_time/space_temporal.rs | 10 +++- .../adjustable_space_time/spatial.rs | 10 +++- .../adjustable_space_time/temporable.rs | 10 +++- .../adjustable_time/adjustable.rs | 8 ++- .../adjustable_time/display.rs | 11 +++- .../adjustable_time/identifiable.rs | 10 +++- .../adjustable_time/mod.rs | 11 +++- .../adjustable_time/temporable.rs | 11 +++- .../src/types/csm_types/csm_state.rs | 34 +++++++++++-- deep_causality/src/types/csm_types/mod.rs | 51 +++++++++++++++++-- deep_causality/src/types/model_types/mod.rs | 21 +++++++- .../reasoning_types/causaloid/causable.rs | 23 ++++++++- .../types/reasoning_types/causaloid/debug.rs | 1 + .../reasoning_types/causaloid/display.rs | 33 ++++++++++-- .../reasoning_types/causaloid/getters.rs | 11 +++- .../reasoning_types/causaloid/identifiable.rs | 11 +++- .../types/reasoning_types/causaloid/mod.rs | 24 ++++++++- .../reasoning_types/causaloid/part_eq.rs | 11 +++- 61 files changed, 742 insertions(+), 83 deletions(-) create mode 100644 deep_causality/src/types/reasoning_types/causaloid/debug.rs diff --git a/deep_causality/src/protocols/contextuable/mod.rs b/deep_causality/src/protocols/contextuable/mod.rs index a4174b5..b41416e 100644 --- a/deep_causality/src/protocols/contextuable/mod.rs +++ b/deep_causality/src/protocols/contextuable/mod.rs @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. +use std::hash::Hash; use std::ops::*; use crate::prelude::{ContextoidType, Identifiable, TimeScale}; @@ -21,7 +22,15 @@ pub trait Datable: Identifiable {} /// pub trait Temporable: Identifiable where - V: Default + Add + Sub + Mul, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn time_scale(&self) -> TimeScale; fn time_unit(&self) -> &V; @@ -42,7 +51,15 @@ where /// pub trait Spatial: Identifiable where - V: Default + Add + Sub + Mul, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn x(&self) -> &V; fn y(&self) -> &V; @@ -64,7 +81,15 @@ where /// pub trait SpaceTemporal: Identifiable + Spatial + Temporable where - V: Default + Add + Sub + Mul, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn t(&self) -> &V; // returns 4th dimension, t } @@ -91,7 +116,15 @@ where S: Spatial, ST: SpaceTemporal, T: Temporable, - V: Default + Add + Sub + Mul, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn vertex_type(&self) -> &ContextoidType; } diff --git a/deep_causality/src/protocols/contextuable_graph/mod.rs b/deep_causality/src/protocols/contextuable_graph/mod.rs index 3b70ac7..f909b58 100644 --- a/deep_causality/src/protocols/contextuable_graph/mod.rs +++ b/deep_causality/src/protocols/contextuable_graph/mod.rs @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. +use std::hash::Hash; use std::ops::{Add, Mul, Sub}; use crate::errors::ContextIndexError; @@ -31,7 +32,15 @@ where S: Spatial, ST: SpaceTemporal, T: Temporable, - V: Default + Add + Sub + Mul, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn add_node(&mut self, value: Contextoid) -> usize; fn contains_node(&self, index: usize) -> bool; @@ -80,7 +89,15 @@ where S: Spatial, ST: SpaceTemporal, T: Temporable, - V: Default + Add + Sub + Mul, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { // Creates a new context and returns the index of the new context. fn extra_ctx_add_new(&mut self, capacity: usize, default: bool) -> u64; diff --git a/deep_causality/src/types/context_types/context_graph/contextuable_graph.rs b/deep_causality/src/types/context_types/context_graph/contextuable_graph.rs index aa13c39..4c8385c 100644 --- a/deep_causality/src/types/context_types/context_graph/contextuable_graph.rs +++ b/deep_causality/src/types/context_types/context_graph/contextuable_graph.rs @@ -9,7 +9,15 @@ where S: Spatial, T: Temporable, ST: SpaceTemporal, - V: Default + Add + Sub + Mul, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { /// Ads a new Contextoid to the context. /// You can add the same contextoid multiple times, diff --git a/deep_causality/src/types/context_types/context_graph/debug.rs b/deep_causality/src/types/context_types/context_graph/debug.rs index 918821f..eb30267 100644 --- a/deep_causality/src/types/context_types/context_graph/debug.rs +++ b/deep_causality/src/types/context_types/context_graph/debug.rs @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. use std::fmt::{Debug, Display, Formatter}; +use std::hash::Hash; use std::ops::*; use crate::prelude::{Context, Datable, SpaceTemporal, Spatial, Temporable}; @@ -12,7 +13,15 @@ where S: Spatial, T: Temporable, ST: SpaceTemporal, - V: Default + Add + Sub + Mul, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn format(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!( @@ -32,7 +41,15 @@ where S: Spatial, T: Temporable, ST: SpaceTemporal, - V: Default + Add + Sub + Mul, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { self.format(f) @@ -45,7 +62,15 @@ where S: Spatial, T: Temporable, ST: SpaceTemporal, - V: Default + Add + Sub + Mul, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { self.format(f) diff --git a/deep_causality/src/types/context_types/context_graph/extendable_contextuable_graph.rs b/deep_causality/src/types/context_types/context_graph/extendable_contextuable_graph.rs index 92523e3..92c6ea7 100644 --- a/deep_causality/src/types/context_types/context_graph/extendable_contextuable_graph.rs +++ b/deep_causality/src/types/context_types/context_graph/extendable_contextuable_graph.rs @@ -10,7 +10,15 @@ where S: Spatial, T: Temporable, ST: SpaceTemporal, - V: Default + Add + Sub + Mul, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn extra_ctx_add_new(&mut self, capacity: usize, default: bool) -> u64 { if self.extra_contexts.is_none() { @@ -191,7 +199,15 @@ where S: Spatial, T: Temporable, ST: SpaceTemporal, - V: Default + Add + Sub + Mul, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn get_current_extra_context( &self, diff --git a/deep_causality/src/types/context_types/context_graph/identifiable.rs b/deep_causality/src/types/context_types/context_graph/identifiable.rs index 461efe2..6bc61a2 100644 --- a/deep_causality/src/types/context_types/context_graph/identifiable.rs +++ b/deep_causality/src/types/context_types/context_graph/identifiable.rs @@ -1,3 +1,4 @@ +use std::hash::Hash; // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. use std::ops::*; @@ -10,7 +11,15 @@ where S: Spatial, T: Temporable, ST: SpaceTemporal, - V: Default + Add + Sub + Mul, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { /// Returns the id of the context. fn id(&self) -> u64 { diff --git a/deep_causality/src/types/context_types/context_graph/indexable.rs b/deep_causality/src/types/context_types/context_graph/indexable.rs index fda818c..ca522e7 100644 --- a/deep_causality/src/types/context_types/context_graph/indexable.rs +++ b/deep_causality/src/types/context_types/context_graph/indexable.rs @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT // Copyright (c) "2024" . The DeepCausality Authors. All Rights Reserved. +use std::hash::Hash; use std::ops::{Add, Mul, Sub}; use crate::prelude::{Context, Datable, Indexable, SpaceTemporal, Spatial, Temporable}; @@ -11,7 +12,15 @@ where S: Spatial, T: Temporable, ST: SpaceTemporal, - V: Default + Add + Sub + Mul, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn get_index(&self, key: &usize, current: bool) -> Option<&usize> { { diff --git a/deep_causality/src/types/context_types/context_graph/mod.rs b/deep_causality/src/types/context_types/context_graph/mod.rs index d8ab80c..3a0a4f1 100644 --- a/deep_causality/src/types/context_types/context_graph/mod.rs +++ b/deep_causality/src/types/context_types/context_graph/mod.rs @@ -2,6 +2,7 @@ // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. use std::collections::HashMap; +use std::hash::Hash; use std::ops::*; use ultragraph::prelude::*; @@ -24,7 +25,15 @@ where S: Spatial, T: Temporable, ST: SpaceTemporal, - V: Default + Add + Sub + Mul, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { id: u64, name: &'l str, @@ -42,7 +51,15 @@ where S: Spatial, T: Temporable, ST: SpaceTemporal, - V: Default + Add + Sub + Mul, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { /// Creates a new context with the given node capacity. pub fn with_capacity(id: u64, name: &'l str, capacity: usize) -> Self { diff --git a/deep_causality/src/types/context_types/contextoid/contextoid_type.rs b/deep_causality/src/types/context_types/contextoid/contextoid_type.rs index eaaf4f4..6eedd1f 100644 --- a/deep_causality/src/types/context_types/contextoid/contextoid_type.rs +++ b/deep_causality/src/types/context_types/contextoid/contextoid_type.rs @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. use std::fmt::{Display, Formatter}; +use std::hash::Hash; use std::marker::PhantomData; use std::ops::*; @@ -25,7 +26,15 @@ where S: Spatial, T: Temporable, ST: SpaceTemporal, - V: Default + Add + Sub + Mul, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { Datoid(D), Tempoid(T), @@ -41,7 +50,15 @@ where S: Spatial, T: Temporable, ST: SpaceTemporal, - V: Default + Add + Sub + Mul, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { pub fn root(&self) -> Option<&Root> { if let ContextoidType::Root(b) = self { @@ -87,7 +104,16 @@ where S: Display + Spatial, T: Display + Temporable, ST: Display + SpaceTemporal, - V: Display + Default + Add + Sub + Mul, + V: Display + + Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { match self { diff --git a/deep_causality/src/types/context_types/contextoid/contextuable.rs b/deep_causality/src/types/context_types/contextoid/contextuable.rs index 07fb3ca..001220f 100644 --- a/deep_causality/src/types/context_types/contextoid/contextuable.rs +++ b/deep_causality/src/types/context_types/contextoid/contextuable.rs @@ -1,3 +1,4 @@ +use std::hash::Hash; // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. use std::ops::*; @@ -12,7 +13,15 @@ where S: Spatial, T: Temporable, ST: SpaceTemporal, - V: Default + Add + Sub + Mul, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn vertex_type(&self) -> &ContextoidType { &self.vertex_type diff --git a/deep_causality/src/types/context_types/contextoid/display.rs b/deep_causality/src/types/context_types/contextoid/display.rs index 58092d1..8de10fb 100644 --- a/deep_causality/src/types/context_types/contextoid/display.rs +++ b/deep_causality/src/types/context_types/contextoid/display.rs @@ -1,4 +1,5 @@ use std::fmt::{Display, Formatter}; +use std::hash::Hash; // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. use std::ops::*; @@ -11,7 +12,16 @@ where S: Spatial + Display, T: Temporable + Display, ST: SpaceTemporal + Display, - V: Default + Add + Sub + Mul + Display, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul + + Display, { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "Contextoid ID: {} Type: {}", self.id, self.vertex_type) diff --git a/deep_causality/src/types/context_types/contextoid/identifiable.rs b/deep_causality/src/types/context_types/contextoid/identifiable.rs index a0080ed..ed4b4a2 100644 --- a/deep_causality/src/types/context_types/contextoid/identifiable.rs +++ b/deep_causality/src/types/context_types/contextoid/identifiable.rs @@ -1,3 +1,4 @@ +use std::hash::Hash; // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. use std::ops::*; @@ -10,7 +11,15 @@ where S: Spatial, T: Temporable, ST: SpaceTemporal, - V: Default + Add + Sub + Mul, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn id(&self) -> u64 { self.id diff --git a/deep_causality/src/types/context_types/contextoid/mod.rs b/deep_causality/src/types/context_types/contextoid/mod.rs index 7e487cb..aebecd6 100644 --- a/deep_causality/src/types/context_types/contextoid/mod.rs +++ b/deep_causality/src/types/context_types/contextoid/mod.rs @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. +use std::hash::Hash; use std::marker::PhantomData; use std::ops::*; @@ -18,7 +19,15 @@ where S: Spatial, T: Temporable, ST: SpaceTemporal, - V: Default + Add + Sub + Mul, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { id: u64, vertex_type: ContextoidType, @@ -31,7 +40,15 @@ where S: Spatial, T: Temporable, ST: SpaceTemporal, - V: Default + Add + Sub + Mul, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { pub fn new(id: u64, vertex_type: ContextoidType) -> Self { Self { diff --git a/deep_causality/src/types/context_types/node_types/data/display.rs b/deep_causality/src/types/context_types/node_types/data/display.rs index 9951147..98d0937 100644 --- a/deep_causality/src/types/context_types/node_types/data/display.rs +++ b/deep_causality/src/types/context_types/node_types/data/display.rs @@ -1,12 +1,13 @@ // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. use std::fmt::{Debug, Display, Formatter}; +use std::hash::Hash; use crate::types::context_types::node_types::data::Data; impl Display for Data where - T: Copy + Default + Debug, + T: Debug + Default + Copy + Clone + Hash + Eq + PartialEq, { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "Dataoid: id: {} data: {:?}", self.id, self.data) diff --git a/deep_causality/src/types/context_types/node_types/data/identifiable.rs b/deep_causality/src/types/context_types/node_types/data/identifiable.rs index 5f8feb5..63b2387 100644 --- a/deep_causality/src/types/context_types/node_types/data/identifiable.rs +++ b/deep_causality/src/types/context_types/node_types/data/identifiable.rs @@ -1,3 +1,5 @@ +use std::hash::Hash; + // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. use crate::prelude::Identifiable; @@ -5,7 +7,7 @@ use crate::types::context_types::node_types::data::Data; impl Identifiable for Data where - T: Copy + Default, + T: Default + Copy + Clone + Hash + Eq + PartialEq, { fn id(&self) -> u64 { self.id diff --git a/deep_causality/src/types/context_types/node_types/data/mod.rs b/deep_causality/src/types/context_types/node_types/data/mod.rs index 4345485..33e8832 100644 --- a/deep_causality/src/types/context_types/node_types/data/mod.rs +++ b/deep_causality/src/types/context_types/node_types/data/mod.rs @@ -1,6 +1,8 @@ // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. +use std::hash::Hash; + use deep_causality_macros::{Constructor, Getters}; use crate::prelude::Datable; @@ -11,7 +13,7 @@ pub mod identifiable; #[derive(Getters, Constructor, Debug, Copy, Clone, Hash, Eq, PartialEq)] pub struct Data where - T: Copy + Default, + T: Default + Copy + Clone + Hash + Eq + PartialEq, { #[getter(name = data_id)] // Rename ID getter to prevent conflict impl with identifiable id: u64, @@ -19,4 +21,4 @@ where } // Type tag required for context. -impl Datable for Data where T: Copy + Default {} +impl Datable for Data where T: Default + Copy + Clone + Hash + Eq + PartialEq {} diff --git a/deep_causality/src/types/context_types/node_types/space/display.rs b/deep_causality/src/types/context_types/node_types/space/display.rs index bb59456..b1a468e 100644 --- a/deep_causality/src/types/context_types/node_types/space/display.rs +++ b/deep_causality/src/types/context_types/node_types/space/display.rs @@ -1,12 +1,22 @@ // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. use std::fmt::{Debug, Display, Formatter}; +use std::hash::Hash; use super::*; impl Display for Space where - T: Default + Debug + Add + Sub + Mul, + T: Debug + + Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { write!( diff --git a/deep_causality/src/types/context_types/node_types/space/identifiable.rs b/deep_causality/src/types/context_types/node_types/space/identifiable.rs index 76346b2..62f33ed 100644 --- a/deep_causality/src/types/context_types/node_types/space/identifiable.rs +++ b/deep_causality/src/types/context_types/node_types/space/identifiable.rs @@ -1,3 +1,4 @@ +use std::hash::Hash; // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. use std::ops::{Add, Mul, Sub}; @@ -7,7 +8,15 @@ use crate::types::context_types::node_types::space::Space; impl Identifiable for Space where - T: Default + Add + Sub + Mul, + T: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn id(&self) -> u64 { self.id diff --git a/deep_causality/src/types/context_types/node_types/space/mod.rs b/deep_causality/src/types/context_types/node_types/space/mod.rs index da09657..e81c3ec 100644 --- a/deep_causality/src/types/context_types/node_types/space/mod.rs +++ b/deep_causality/src/types/context_types/node_types/space/mod.rs @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. +use std::hash::Hash; use std::ops::{Add, Mul, Sub}; use deep_causality_macros::Constructor; @@ -12,7 +13,15 @@ mod spatial; #[derive(Constructor, Debug, Copy, Clone, Hash, Eq, PartialEq)] pub struct Space where - T: Default + Add + Sub + Mul, + T: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { id: u64, x: T, diff --git a/deep_causality/src/types/context_types/node_types/space/spatial.rs b/deep_causality/src/types/context_types/node_types/space/spatial.rs index 40547ca..9fa329f 100644 --- a/deep_causality/src/types/context_types/node_types/space/spatial.rs +++ b/deep_causality/src/types/context_types/node_types/space/spatial.rs @@ -1,3 +1,4 @@ +use std::hash::Hash; // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. use std::ops::{Add, Mul, Sub}; @@ -8,7 +9,15 @@ use super::*; impl Spatial for Space where - T: Default + Add + Sub + Mul, + T: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn x(&self) -> &T { &self.x diff --git a/deep_causality/src/types/context_types/node_types/space_time/display.rs b/deep_causality/src/types/context_types/node_types/space_time/display.rs index 07a41f0..b700688 100644 --- a/deep_causality/src/types/context_types/node_types/space_time/display.rs +++ b/deep_causality/src/types/context_types/node_types/space_time/display.rs @@ -1,13 +1,23 @@ // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. use std::fmt::{Debug, Display, Formatter}; +use std::hash::Hash; use std::ops::{Add, Mul, Sub}; use crate::types::context_types::node_types::space_time::SpaceTime; impl Display for SpaceTime where - T: Copy + Debug + Default + Add + Sub + Mul, + T: Debug + + Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!( diff --git a/deep_causality/src/types/context_types/node_types/space_time/identifiable.rs b/deep_causality/src/types/context_types/node_types/space_time/identifiable.rs index d6bc8b3..ebf1b47 100644 --- a/deep_causality/src/types/context_types/node_types/space_time/identifiable.rs +++ b/deep_causality/src/types/context_types/node_types/space_time/identifiable.rs @@ -1,3 +1,4 @@ +use std::hash::Hash; // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. use std::ops::{Add, Mul, Sub}; @@ -7,7 +8,15 @@ use crate::types::context_types::node_types::space_time::SpaceTime; impl Identifiable for SpaceTime where - T: Default + Add + Sub + Mul, + T: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn id(&self) -> u64 { self.id diff --git a/deep_causality/src/types/context_types/node_types/space_time/mod.rs b/deep_causality/src/types/context_types/node_types/space_time/mod.rs index 587840c..dc27607 100644 --- a/deep_causality/src/types/context_types/node_types/space_time/mod.rs +++ b/deep_causality/src/types/context_types/node_types/space_time/mod.rs @@ -1,3 +1,4 @@ +use std::hash::Hash; // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. use std::ops::*; @@ -15,7 +16,15 @@ mod temporable; #[derive(Constructor, Debug, Copy, Clone, Hash, Eq, PartialEq)] pub struct SpaceTime where - T: Default + Add + Sub + Mul, + T: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { id: u64, time_scale: TimeScale, diff --git a/deep_causality/src/types/context_types/node_types/space_time/space_temporal.rs b/deep_causality/src/types/context_types/node_types/space_time/space_temporal.rs index e5bf1a2..20583ca 100644 --- a/deep_causality/src/types/context_types/node_types/space_time/space_temporal.rs +++ b/deep_causality/src/types/context_types/node_types/space_time/space_temporal.rs @@ -1,3 +1,4 @@ +use std::hash::Hash; // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. use std::ops::{Add, Mul, Sub}; @@ -7,7 +8,15 @@ use crate::types::context_types::node_types::space_time::SpaceTime; impl SpaceTemporal for SpaceTime where - T: Default + Add + Sub + Mul, + T: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn t(&self) -> &T { &self.time_unit diff --git a/deep_causality/src/types/context_types/node_types/space_time/spatial.rs b/deep_causality/src/types/context_types/node_types/space_time/spatial.rs index c37e8b6..90babce 100644 --- a/deep_causality/src/types/context_types/node_types/space_time/spatial.rs +++ b/deep_causality/src/types/context_types/node_types/space_time/spatial.rs @@ -1,3 +1,4 @@ +use std::hash::Hash; // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. use std::ops::{Add, Mul, Sub}; @@ -7,7 +8,15 @@ use crate::types::context_types::node_types::space_time::SpaceTime; impl Spatial for SpaceTime where - T: Default + Add + Sub + Mul, + T: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn x(&self) -> &T { &self.x diff --git a/deep_causality/src/types/context_types/node_types/space_time/temporable.rs b/deep_causality/src/types/context_types/node_types/space_time/temporable.rs index a1cc01b..81dfce9 100644 --- a/deep_causality/src/types/context_types/node_types/space_time/temporable.rs +++ b/deep_causality/src/types/context_types/node_types/space_time/temporable.rs @@ -1,3 +1,4 @@ +use std::hash::Hash; // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. use std::ops::{Add, Mul, Sub}; @@ -7,7 +8,15 @@ use crate::types::context_types::node_types::space_time::SpaceTime; impl Temporable for SpaceTime where - T: Default + Add + Sub + Mul, + T: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn time_scale(&self) -> TimeScale { self.time_scale diff --git a/deep_causality/src/types/context_types/node_types/time/display.rs b/deep_causality/src/types/context_types/node_types/time/display.rs index c3745e1..53a502b 100644 --- a/deep_causality/src/types/context_types/node_types/time/display.rs +++ b/deep_causality/src/types/context_types/node_types/time/display.rs @@ -1,13 +1,23 @@ // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. use std::fmt::{Debug, Display}; +use std::hash::Hash; use std::ops::{Add, Mul, Sub}; use crate::types::context_types::node_types::time::Time; impl Display for Time where - T: Debug + Default + Add + Sub + Mul, + T: Debug + + Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!( diff --git a/deep_causality/src/types/context_types/node_types/time/identifiable.rs b/deep_causality/src/types/context_types/node_types/time/identifiable.rs index f1ad2be..132459e 100644 --- a/deep_causality/src/types/context_types/node_types/time/identifiable.rs +++ b/deep_causality/src/types/context_types/node_types/time/identifiable.rs @@ -1,3 +1,4 @@ +use std::hash::Hash; // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. use std::ops::{Add, Mul, Sub}; @@ -7,7 +8,15 @@ use crate::types::context_types::node_types::time::Time; impl Identifiable for Time where - T: Default + Add + Sub + Mul, + T: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn id(&self) -> u64 { self.id diff --git a/deep_causality/src/types/context_types/node_types/time/mod.rs b/deep_causality/src/types/context_types/node_types/time/mod.rs index df1d8fa..cb5eb38 100644 --- a/deep_causality/src/types/context_types/node_types/time/mod.rs +++ b/deep_causality/src/types/context_types/node_types/time/mod.rs @@ -1,3 +1,4 @@ +use std::hash::Hash; // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. use std::ops::*; @@ -13,7 +14,15 @@ mod temporable; #[derive(Constructor, Debug, Copy, Clone, Hash, Eq, PartialEq)] pub struct Time where - T: Default + Add + Sub + Mul, + T: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { id: u64, time_scale: TimeScale, diff --git a/deep_causality/src/types/context_types/node_types/time/temporable.rs b/deep_causality/src/types/context_types/node_types/time/temporable.rs index 38d603e..8b21164 100644 --- a/deep_causality/src/types/context_types/node_types/time/temporable.rs +++ b/deep_causality/src/types/context_types/node_types/time/temporable.rs @@ -1,3 +1,4 @@ +use std::hash::Hash; // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. use std::ops::{Add, Mul, Sub}; @@ -7,7 +8,15 @@ use crate::types::context_types::node_types::time::Time; impl Temporable for Time where - T: Default + Add + Sub + Mul, + T: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn time_scale(&self) -> TimeScale { self.time_scale diff --git a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_data/adjustable.rs b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_data/adjustable.rs index 0091e2d..b75659d 100644 --- a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_data/adjustable.rs +++ b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_data/adjustable.rs @@ -16,6 +16,9 @@ where + Sub + Mul + Copy + + Clone + + Hash + + Eq + PartialEq + PartialOrd, { diff --git a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_data/display.rs b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_data/display.rs index 098ad53..f27e489 100644 --- a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_data/display.rs +++ b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_data/display.rs @@ -6,7 +6,7 @@ use super::*; impl Display for AdjustableData where - T: Copy + Default + Debug, + T: Debug + Default + Copy + Clone + Hash + Eq + PartialEq, { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "AdjustableData: id: {} data: {:?}", self.id, self.data) diff --git a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_data/identifiable.rs b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_data/identifiable.rs index bd46273..6788a24 100644 --- a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_data/identifiable.rs +++ b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_data/identifiable.rs @@ -6,7 +6,7 @@ use super::*; impl Identifiable for AdjustableData where - T: Copy + Default, + T: Default + Copy + Clone + Hash + Eq + PartialEq, { fn id(&self) -> u64 { self.id diff --git a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_data/mod.rs b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_data/mod.rs index 5fa3ad6..c3197f1 100644 --- a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_data/mod.rs +++ b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_data/mod.rs @@ -1,3 +1,5 @@ +use std::hash::Hash; + use deep_causality_macros::{Constructor, Getters}; // SPDX-License-Identifier: MIT @@ -11,7 +13,7 @@ mod identifiable; #[derive(Getters, Constructor, Debug, Copy, Clone, Hash, Eq, PartialEq)] pub struct AdjustableData where - T: Copy + Default, + T: Default + Copy + Clone + Hash + Eq + PartialEq, { #[getter(name = data_id)] // Rename ID getter to prevent conflict impl with identifiable id: u64, @@ -19,4 +21,4 @@ where } // Type tag required for context. -impl Datable for AdjustableData where T: Copy + Default {} +impl Datable for AdjustableData where T: Default + Copy + Clone + Hash + Eq + PartialEq {} diff --git a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space/adjustable.rs b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space/adjustable.rs index e0b1080..b6bad21 100644 --- a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space/adjustable.rs +++ b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space/adjustable.rs @@ -19,6 +19,9 @@ where + Sub + Mul + Copy + + Clone + + Hash + + Eq + PartialEq + PartialOrd, { diff --git a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space/display.rs b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space/display.rs index 2a1bcba..3994dc7 100644 --- a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space/display.rs +++ b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space/display.rs @@ -6,7 +6,16 @@ use super::*; impl Display for AdjustableSpace where - T: Default + Debug + Add + Sub + Mul + Copy, + T: Debug + + Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn fmt(&self, f: &mut Formatter) -> std::fmt::Result { write!( diff --git a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space/identifiable.rs b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space/identifiable.rs index 1cdbc2d..4cab444 100644 --- a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space/identifiable.rs +++ b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space/identifiable.rs @@ -6,7 +6,15 @@ use super::*; impl Identifiable for AdjustableSpace where - T: Default + Add + Sub + Mul + Copy, + T: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn id(&self) -> u64 { self.id diff --git a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space/mod.rs b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space/mod.rs index 7790435..ec76870 100644 --- a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space/mod.rs +++ b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space/mod.rs @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. +use std::hash::Hash; use std::ops::*; use deep_causality_macros::{Constructor, Getters}; @@ -13,7 +14,15 @@ mod spatial; #[derive(Getters, Constructor, Debug, Copy, Clone, Hash, Eq, PartialEq)] pub struct AdjustableSpace where - T: Default + Add + Sub + Mul + Copy, + T: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { #[getter(name = space_id)] // Rename ID getter to prevent conflict impl with identifiable id: u64, diff --git a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space/spatial.rs b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space/spatial.rs index 5376759..345b051 100644 --- a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space/spatial.rs +++ b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space/spatial.rs @@ -7,7 +7,15 @@ use super::*; impl Spatial for AdjustableSpace where - T: Default + Add + Sub + Mul + Copy, + T: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn x(&self) -> &T { &self.x diff --git a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space_time/adjustable.rs b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space_time/adjustable.rs index cae2376..8fe0cbc 100644 --- a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space_time/adjustable.rs +++ b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space_time/adjustable.rs @@ -1,3 +1,5 @@ +use std::fmt::Debug; +use std::hash::Hash; use std::ops::Add; // SPDX-License-Identifier: MIT @@ -11,11 +13,15 @@ use super::*; impl Adjustable for AdjustableSpaceTime where - T: Default + T: Debug + + Default + Add + Sub + Mul + Copy + + Clone + + Hash + + Eq + PartialEq + PartialOrd, { diff --git a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space_time/display.rs b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space_time/display.rs index 8d16ad5..bcc274a 100644 --- a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space_time/display.rs +++ b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space_time/display.rs @@ -1,12 +1,22 @@ // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. -use std::fmt::{Display, Formatter}; +use std::fmt::{Debug, Display, Formatter}; use super::*; impl Display for AdjustableSpaceTime where - T: Copy + Display + Default + Add + Sub + Mul, + T: Debug + + Display + + Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!( diff --git a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space_time/identifiable.rs b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space_time/identifiable.rs index 3151c62..20c343e 100644 --- a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space_time/identifiable.rs +++ b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space_time/identifiable.rs @@ -6,7 +6,15 @@ use super::*; impl Identifiable for AdjustableSpaceTime where - T: Default + Add + Sub + Mul + Copy, + T: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn id(&self) -> u64 { self.id diff --git a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space_time/mod.rs b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space_time/mod.rs index 0d2aa07..4b7e064 100644 --- a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space_time/mod.rs +++ b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space_time/mod.rs @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. +use std::hash::Hash; use std::ops::*; use deep_causality_macros::{Constructor, Getters}; @@ -17,7 +18,15 @@ mod temporable; #[derive(Getters, Constructor, Debug, Copy, Clone, Hash, Eq, PartialEq)] pub struct AdjustableSpaceTime where - T: Default + Add + Sub + Mul + Copy, + T: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { #[getter(name = time_id)] // Rename ID getter to prevent conflict impl with identifiable id: u64, diff --git a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space_time/space_temporal.rs b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space_time/space_temporal.rs index 9ae6353..1c02889 100644 --- a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space_time/space_temporal.rs +++ b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space_time/space_temporal.rs @@ -6,7 +6,15 @@ use super::*; impl SpaceTemporal for AdjustableSpaceTime where - T: Default + Add + Sub + Mul + Copy, + T: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn t(&self) -> &T { &self.time_unit diff --git a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space_time/spatial.rs b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space_time/spatial.rs index 7f0bbe0..dfff5b3 100644 --- a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space_time/spatial.rs +++ b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space_time/spatial.rs @@ -6,7 +6,15 @@ use super::*; impl Spatial for AdjustableSpaceTime where - T: Default + Add + Sub + Mul + Copy, + T: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn x(&self) -> &T { &self.x diff --git a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space_time/temporable.rs b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space_time/temporable.rs index 46f46dc..b5399d8 100644 --- a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space_time/temporable.rs +++ b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_space_time/temporable.rs @@ -8,7 +8,15 @@ use super::*; impl Temporable for AdjustableSpaceTime where - T: Default + Add + Sub + Mul + Copy, + T: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn time_scale(&self) -> TimeScale { self.time_scale diff --git a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_time/adjustable.rs b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_time/adjustable.rs index 3516de1..2fd83ef 100644 --- a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_time/adjustable.rs +++ b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_time/adjustable.rs @@ -1,6 +1,8 @@ // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. +use std::fmt::Debug; +use std::hash::Hash; use std::ops::*; use dcl_data_structures::grid_type::ArrayGrid; @@ -11,11 +13,15 @@ use crate::prelude::{Adjustable, AdjustableTime}; impl Adjustable for AdjustableTime where - T: Default + T: Debug + + Default + Add + Sub + Mul + Copy + + Clone + + Hash + + Eq + PartialEq + PartialOrd, { diff --git a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_time/display.rs b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_time/display.rs index 941d588..70102f6 100644 --- a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_time/display.rs +++ b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_time/display.rs @@ -6,7 +6,16 @@ use super::*; impl Display for AdjustableTime where - T: Debug + Default + Add + Sub + Mul + Copy, + T: Debug + + Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!( diff --git a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_time/identifiable.rs b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_time/identifiable.rs index e739e82..7441f2d 100644 --- a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_time/identifiable.rs +++ b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_time/identifiable.rs @@ -6,7 +6,15 @@ use super::*; impl Identifiable for AdjustableTime where - T: Default + Add + Sub + Mul + Copy, + T: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn id(&self) -> u64 { self.id diff --git a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_time/mod.rs b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_time/mod.rs index 9e0874f..8515e31 100644 --- a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_time/mod.rs +++ b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_time/mod.rs @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. +use std::hash::Hash; use std::ops::*; use deep_causality_macros::{Constructor, Getters}; @@ -15,7 +16,15 @@ mod temporable; #[derive(Getters, Constructor, Debug, Copy, Clone, Hash, Eq, PartialEq)] pub struct AdjustableTime where - T: Default + Add + Sub + Mul + Copy, + T: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { #[getter(name = time_id)] // Rename ID getter to prevent conflict impl with identifiable id: u64, diff --git a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_time/temporable.rs b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_time/temporable.rs index 9616a93..7bd9404 100644 --- a/deep_causality/src/types/context_types/node_types_adjustable/adjustable_time/temporable.rs +++ b/deep_causality/src/types/context_types/node_types_adjustable/adjustable_time/temporable.rs @@ -1,3 +1,4 @@ +use std::hash::Hash; // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. use std::ops::{Add, Mul, Sub}; @@ -6,7 +7,15 @@ use crate::prelude::{AdjustableTime, Temporable, TimeScale}; impl Temporable for AdjustableTime where - T: Default + Add + Sub + Mul + Copy, + T: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn time_scale(&self) -> TimeScale { self.time_scale diff --git a/deep_causality/src/types/csm_types/csm_state.rs b/deep_causality/src/types/csm_types/csm_state.rs index 249daa7..fdefeb1 100644 --- a/deep_causality/src/types/csm_types/csm_state.rs +++ b/deep_causality/src/types/csm_types/csm_state.rs @@ -2,6 +2,7 @@ // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. use std::fmt::{Debug, Display, Formatter}; +use std::hash::Hash; use std::ops::*; use deep_causality_macros::{Constructor, Getters}; @@ -18,7 +19,16 @@ where S: Spatial + Clone, T: Temporable + Clone, ST: SpaceTemporal + Clone, - V: Default + Add + Sub + Mul + Clone, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul + + Clone, { id: usize, version: usize, @@ -32,7 +42,16 @@ where S: Spatial + Clone, T: Temporable + Clone, ST: SpaceTemporal + Clone, - V: Default + Add + Sub + Mul + Clone, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul + + Clone, { pub fn eval(&self) -> Result { self.causaloid.verify_single_cause(&self.data) @@ -56,7 +75,16 @@ where S: Spatial + Clone, T: Temporable + Clone, ST: SpaceTemporal + Clone, - V: Default + Add + Sub + Mul + Clone, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul + + Clone, { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { self.fmt_print(f) diff --git a/deep_causality/src/types/csm_types/mod.rs b/deep_causality/src/types/csm_types/mod.rs index e986766..f94fa66 100644 --- a/deep_causality/src/types/csm_types/mod.rs +++ b/deep_causality/src/types/csm_types/mod.rs @@ -3,6 +3,7 @@ use std::cell::RefCell; use std::collections::HashMap; +use std::hash::Hash; use std::ops::{Add, Mul, Sub}; use crate::errors::{ActionError, UpdateError}; @@ -24,7 +25,15 @@ where S: Spatial + Clone + Copy, T: Temporable + Clone + Copy, ST: SpaceTemporal + Clone + Copy, - V: Default + Add + Sub + Mul + Clone, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { state_actions: RefCell>, } @@ -35,7 +44,15 @@ where S: Spatial + Clone + Copy, T: Temporable + Clone + Copy, ST: SpaceTemporal + Clone + Copy, - V: Default + Add + Sub + Mul + Clone, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { /// Constructs a new CSM. pub fn new(state_actions: &'l CSMStateActions<'l, D, S, T, ST, V>) -> Self { @@ -67,7 +84,15 @@ where S: Spatial + Clone + Copy, T: Temporable + Clone + Copy, ST: SpaceTemporal + Clone + Copy, - V: Default + Add + Sub + Mul + Clone, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { /// Inserts a new state action at the index position idx. /// Returns UpdateError if the index already exists. @@ -115,7 +140,15 @@ where S: Spatial + Clone + Copy, T: Temporable + Clone + Copy, ST: SpaceTemporal + Clone + Copy, - V: Default + Add + Sub + Mul + Clone, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { /// Evaluates a single causal state at the index position idx. /// Returns ActionError if the evaluation failed. @@ -189,7 +222,15 @@ where S: Spatial + Clone + Copy, T: Temporable + Clone + Copy, ST: SpaceTemporal + Clone + Copy, - V: Default + Add + Sub + Mul + Clone, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { /// Evaluates all causal states in the CSM. /// Returns ActionError if the evaluation failed. diff --git a/deep_causality/src/types/model_types/mod.rs b/deep_causality/src/types/model_types/mod.rs index 2630f5e..fafd5fc 100644 --- a/deep_causality/src/types/model_types/mod.rs +++ b/deep_causality/src/types/model_types/mod.rs @@ -1,3 +1,4 @@ +use std::hash::Hash; // SPDX-License-Identifier: MIT // Copyright (c) "2023" . Marvin Hansen All rights reserved. use std::ops::*; @@ -15,7 +16,15 @@ where S: Spatial + Clone, T: Temporable + Clone, ST: SpaceTemporal + Clone, - V: Default + Add + Sub + Mul + Clone, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { #[getter(name = model_id)] // Rename ID getter to prevent conflict impl with identifiable id: u64, @@ -32,7 +41,15 @@ where S: Spatial + Clone, T: Temporable + Clone, ST: SpaceTemporal + Clone, - V: Default + Add + Sub + Mul + Clone, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul, { fn id(&self) -> u64 { self.id diff --git a/deep_causality/src/types/reasoning_types/causaloid/causable.rs b/deep_causality/src/types/reasoning_types/causaloid/causable.rs index b3c99b0..bbee767 100644 --- a/deep_causality/src/types/reasoning_types/causaloid/causable.rs +++ b/deep_causality/src/types/reasoning_types/causaloid/causable.rs @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT // Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved. use std::collections::HashMap; +use std::hash::Hash; use std::ops::*; use crate::errors::CausalityError; @@ -16,7 +17,16 @@ where S: Spatial + Clone, T: Temporable + Clone, ST: SpaceTemporal + Clone, - V: Default + Add + Sub + Mul + Clone, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul + + Clone, { fn explain(&self) -> Result { return if self.active.get() { @@ -147,7 +157,16 @@ where S: Spatial + Clone, T: Temporable + Clone, ST: SpaceTemporal + Clone, - V: Default + Add + Sub + Mul + Clone, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul + + Clone, { #[inline(always)] fn check_active(&self, res: bool) -> bool { diff --git a/deep_causality/src/types/reasoning_types/causaloid/debug.rs b/deep_causality/src/types/reasoning_types/causaloid/debug.rs new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/deep_causality/src/types/reasoning_types/causaloid/debug.rs @@ -0,0 +1 @@ + diff --git a/deep_causality/src/types/reasoning_types/causaloid/display.rs b/deep_causality/src/types/reasoning_types/causaloid/display.rs index 319ecc2..0d2e911 100644 --- a/deep_causality/src/types/reasoning_types/causaloid/display.rs +++ b/deep_causality/src/types/reasoning_types/causaloid/display.rs @@ -9,7 +9,16 @@ where S: Spatial + Clone, T: Temporable + Clone, ST: SpaceTemporal + Clone, - V: Default + Add + Sub + Mul + Clone, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul + + Debug, { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { self.fmt(f) @@ -22,7 +31,16 @@ where S: Spatial + Clone, T: Temporable + Clone, ST: SpaceTemporal + Clone, - V: Default + Add + Sub + Mul + Clone, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul + + Clone, { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { self.fmt(f) @@ -35,7 +53,16 @@ where S: Spatial + Clone, T: Temporable + Clone, ST: SpaceTemporal + Clone, - V: Default + Add + Sub + Mul + Clone, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul + + Clone, { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!(f, "Causaloid id: {} \n Causaloid type: {} \n description: {} is active: {} has context: {}", diff --git a/deep_causality/src/types/reasoning_types/causaloid/getters.rs b/deep_causality/src/types/reasoning_types/causaloid/getters.rs index 541098b..9c67117 100644 --- a/deep_causality/src/types/reasoning_types/causaloid/getters.rs +++ b/deep_causality/src/types/reasoning_types/causaloid/getters.rs @@ -10,7 +10,16 @@ where S: Spatial + Clone, T: Temporable + Clone, ST: SpaceTemporal + Clone, - V: Default + Add + Sub + Mul + Clone, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul + + Clone, { pub fn active(&self) -> bool { self.active.get() diff --git a/deep_causality/src/types/reasoning_types/causaloid/identifiable.rs b/deep_causality/src/types/reasoning_types/causaloid/identifiable.rs index 5a0272e..ec098fa 100644 --- a/deep_causality/src/types/reasoning_types/causaloid/identifiable.rs +++ b/deep_causality/src/types/reasoning_types/causaloid/identifiable.rs @@ -9,7 +9,16 @@ where S: Spatial + Clone, T: Temporable + Clone, ST: SpaceTemporal + Clone, - V: Default + Add + Sub + Mul + Clone, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul + + Clone, { fn id(&self) -> u64 { self.id diff --git a/deep_causality/src/types/reasoning_types/causaloid/mod.rs b/deep_causality/src/types/reasoning_types/causaloid/mod.rs index 3454106..4e1fad2 100644 --- a/deep_causality/src/types/reasoning_types/causaloid/mod.rs +++ b/deep_causality/src/types/reasoning_types/causaloid/mod.rs @@ -3,6 +3,7 @@ use std::cell::Cell; use std::fmt::{Debug, Display, Formatter}; +use std::hash::Hash; use std::marker::PhantomData; use std::ops::*; @@ -11,6 +12,7 @@ use crate::types::reasoning_types::causaloid::causal_type::CausalType; mod causable; mod causal_type; +mod debug; mod display; mod getters; mod identifiable; @@ -25,7 +27,16 @@ where S: Spatial + Clone, T: Temporable + Clone, ST: SpaceTemporal + Clone, - V: Default + Add + Sub + Mul + Clone, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul + + Clone, { id: IdentificationValue, active: Cell, @@ -48,7 +59,16 @@ where S: Spatial + Clone, T: Temporable + Clone, ST: SpaceTemporal + Clone, - V: Default + Add + Sub + Mul + Clone, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul + + Clone, { /// Singleton constructor. Assumes causality function is valid. /// Only use for non-fallible construction i.e.verified a-priori knowledge about the correctness of the causal function. diff --git a/deep_causality/src/types/reasoning_types/causaloid/part_eq.rs b/deep_causality/src/types/reasoning_types/causaloid/part_eq.rs index 5a42247..9f02ca7 100644 --- a/deep_causality/src/types/reasoning_types/causaloid/part_eq.rs +++ b/deep_causality/src/types/reasoning_types/causaloid/part_eq.rs @@ -9,7 +9,16 @@ where S: Spatial + Clone, T: Temporable + Clone, ST: SpaceTemporal + Clone, - V: Default + Add + Sub + Mul + Clone, + V: Default + + Copy + + Clone + + Hash + + Eq + + PartialEq + + Add + + Sub + + Mul + + Clone, { fn eq(&self, other: &Self) -> bool { self.id == other.id