Skip to main content

microcad_lang/model/
creator.rs

1// Copyright © 2025-2026 The µcad authors <info@microcad.xyz>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4//! Creator of work pieces.
5
6use crate::{symbol::Symbol, value::Tuple};
7
8/// A creator is the origin  
9#[derive(Debug, Clone)]
10pub struct Creator {
11    /// Symbol.
12    pub symbol: Symbol,
13    /// Workpiece arguments.
14    pub arguments: Tuple,
15}
16
17impl Creator {
18    /// New creator.
19    pub fn new(symbol: Symbol, arguments: Tuple) -> Self {
20        Self { symbol, arguments }
21    }
22}
23
24impl std::fmt::Display for Creator {
25    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26        write!(
27            f,
28            "{symbol}{arguments}",
29            symbol = self.symbol.full_name(),
30            arguments = self.arguments
31        )
32    }
33}
34
35impl std::hash::Hash for Creator {
36    fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
37        self.symbol.full_name().hash(state);
38        self.arguments.hash(state);
39    }
40}