diff --git a/btypes_primitives/src/main/rust/btypes/src/bobject.rs b/btypes_primitives/src/main/rust/btypes/src/bobject.rs index 3a021f52840597f05549c7e3cbb0653c7edf0711..6e784d252417c0d95f87a9994b5a4d338150c890 100644 --- a/btypes_primitives/src/main/rust/btypes/src/bobject.rs +++ b/btypes_primitives/src/main/rust/btypes/src/bobject.rs @@ -1,8 +1,16 @@ use std::hash::Hash; use std::clone::Clone; -use std::fmt::Display; +use std::fmt; use crate::bboolean::{BBoolean, BBooleanT}; -pub trait BObject: Eq + Hash + Ord + Clone + Display { +pub trait BObject: Eq + Hash + Ord + Clone + fmt::Display { fn is_struct(&self) -> BBoolean { BBoolean::new(false) } -} \ No newline at end of file +} + +#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] +pub struct Dummy {} +impl fmt::Display for Dummy { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "None") } +} + +impl BObject for Dummy {} diff --git a/src/main/resources/de/hhu/stups/codegenerator/RustTemplate.stg b/src/main/resources/de/hhu/stups/codegenerator/RustTemplate.stg index 4885e4d9194b8c87a193f14cf4996099cf93de35..c7c6468c22c7dcd0e5b87830d2ac8e7df8753d4d 100644 --- a/src/main/resources/de/hhu/stups/codegenerator/RustTemplate.stg +++ b/src/main/resources/de/hhu/stups/codegenerator/RustTemplate.stg @@ -19,6 +19,7 @@ use std::time::{Duration}; use std::fmt; use rand::{thread_rng, Rng}; use btypes::butils; +use btypes::bobject; use btypes::bboolean::{IntoBool, BBooleanT}; <imports; separator="\n"> <includedMachines; separator="\n"> @@ -406,7 +407,7 @@ if_expression_predicate(predicate, ifThen, ifElse) ::= << >> set_enumeration(leftType, type, rightType, enums, isRelation) ::= << -<if(isRelation)>BRelation::new<else>BSet::new<endif>(vec![<enums; separator=", ">]) +<if(isRelation)>BRelation<if(!type)>::\<bobject::Dummy, bobject::Dummy><endif><else>BSet<if(!type)>::\<bobject::Dummy><endif><endif>::new(vec![<enums; separator=", ">]) >> seq_enumeration(type, elements) ::= <<