microcad_lang/ty/matrix_type.rs
1// Copyright © 2025 The µcad authors <info@ucad.xyz>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4//! Matrix type
5
6/// M x N Matrix Type.
7#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
8pub struct MatrixType {
9 /// Number of rows.
10 pub rows: usize,
11 /// Number of columns.
12 pub columns: usize,
13}
14
15impl MatrixType {
16 /// Create new matrix type with rows and columns
17 pub fn new(rows: usize, columns: usize) -> Self {
18 Self { rows, columns }
19 }
20}
21
22impl std::fmt::Display for MatrixType {
23 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
24 write!(f, "Matrix{}x{}", self.rows, self.columns)
25 }
26}