microcad_lang/model/
creator.rs

1// Copyright © 2025 The µcad authors <info@ucad.xyz>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4//! Creator of work pieces.
5
6use crate::{resolve::*, 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 Info for Creator {
25    fn info(&self) -> SymbolInfo {
26        self.symbol.info()
27    }
28}
29
30impl std::fmt::Display for Creator {
31    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
32        write!(
33            f,
34            "{symbol}{arguments}",
35            symbol = self.symbol.full_name(),
36            arguments = self.arguments
37        )
38    }
39}
40
41impl std::hash::Hash for Creator {
42    fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
43        self.symbol.full_name().hash(state);
44        self.arguments.hash(state);
45    }
46}