From 1713618d4cc0194674f91fd2d24ef2de88f21784 Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Thu, 18 Jan 2024 18:29:10 +0100 Subject: create small iced demo --- src/context.rs | 66 ---------------------------------------------------------- 1 file changed, 66 deletions(-) delete mode 100644 src/context.rs (limited to 'src/context.rs') diff --git a/src/context.rs b/src/context.rs deleted file mode 100644 index 409600f..0000000 --- a/src/context.rs +++ /dev/null @@ -1,66 +0,0 @@ -use crate::complex::Complex; -use crate::function::Function; -use crate::operation::Operation; -use std::sync::Arc; -use std::collections::HashMap; - -#[derive(Default, Clone)] -pub struct Context { - ops: Vec, - vars: HashMap, - funcs: HashMap>, -} - -impl Context { - pub fn new() -> Self { - Self::default() - } - - pub fn with_operations(mut self, ops: Vec) -> Self { - self.ops = ops; - self - } - - pub fn with_variables(mut self, vars: HashMap) -> Self { - self.vars = vars; - self - } - - pub fn with_functions(mut self, funcs: HashMap>) -> Self { - self.funcs = funcs; - self - } - - pub fn operations(&self) -> &Vec { - &self.ops - } - - pub fn set_variable(&mut self, name: &str, value: Complex) { - self.vars.insert(name.to_string(), value); - } - - pub fn set_function(&mut self, name: &str, func: Arc) { - self.funcs.insert(name.to_string(), func); - } - - pub fn variable(&self, name: &str) -> Option<&Complex> { - self.vars.get(name) - } - - pub fn function(&self, name: &str) -> Option<&Arc> { - self.funcs.get(name) - } -} - -#[macro_export] -macro_rules! variables { - {$($x:expr => $y:expr), *} => { - { - let mut h : HashMap = HashMap::new(); - $( - h.insert($x.to_string(), $y); - )* - h - } - }; -} -- cgit v1.2.3-70-g09d2