diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-03-13 21:39:38 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-03-13 21:40:06 +0100 |
| commit | 880b1847bd4170ce80be5781c2163ba085cdcaff (patch) | |
| tree | 3fbfdb70cb04c4922f0ec9e3f29f2c63d11d753b /library/src/math | |
| parent | cb3c263c4a67f4d361dbdb5048a1c073bd1fff96 (diff) | |
Derive `Cast` for enums
Diffstat (limited to 'library/src/math')
| -rw-r--r-- | library/src/math/matrix.rs | 36 |
1 files changed, 11 insertions, 25 deletions
diff --git a/library/src/math/matrix.rs b/library/src/math/matrix.rs index 148d79e8..d79c7ca5 100644 --- a/library/src/math/matrix.rs +++ b/library/src/math/matrix.rs @@ -169,12 +169,22 @@ impl LayoutMath for CasesNode { } /// A vector / matrix delimiter. -#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] +#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Cast)] pub enum Delimiter { + /// Delimit with parentheses. + #[string("(")] Paren, + /// Delimit with brackets. + #[string("[")] Bracket, + /// Delimit with curly braces. + #[string("{")] Brace, + /// Delimit with vertical bars. + #[string("|")] Bar, + /// Delimit with double vertical bars. + #[string("||")] DoubleBar, } @@ -202,30 +212,6 @@ impl Delimiter { } } -cast_from_value! { - Delimiter, - /// Delimit with parentheses. - "(" => Self::Paren, - /// Delimit with brackets. - "[" => Self::Bracket, - /// Delimit with curly braces. - "{" => Self::Brace, - /// Delimit with vertical bars. - "|" => Self::Bar, - /// Delimit with double vertical bars. - "||" => Self::DoubleBar, -} - -cast_to_value! { - v: Delimiter => Value::from(match v { - Delimiter::Paren => "(", - Delimiter::Bracket => "[", - Delimiter::Brace => "{", - Delimiter::Bar => "|", - Delimiter::DoubleBar => "||", - }) -} - /// Layout the inner contents of a vector. fn layout_vec_body( ctx: &mut MathContext, |
