From ee18ae3222761f7d7c7f039ee9e816399069d215 Mon Sep 17 00:00:00 2001 From: electria Date: Wed, 15 Jul 2026 21:51:12 -0700 Subject: [PATCH] fix: recognize unary operators --- src/nodes/from_str.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/nodes/from_str.rs b/src/nodes/from_str.rs index 8b6d819..57bf3e3 100644 --- a/src/nodes/from_str.rs +++ b/src/nodes/from_str.rs @@ -78,9 +78,13 @@ impl FromStr for Nodes { } else if c == ')' { nodes.push(Node::ParenthesisEnd); } else { - nodes.push(Node::Operator( - c.try_into().map_err(|()| Error::InvalidOperator(c))?, - )); + if matches!(nodes.last(), Some(Node::Operator(_)) | None) { + state = ParsingState::ReadingNumber(i); + } else { + nodes.push(Node::Operator( + c.try_into().map_err(|()| Error::InvalidOperator(c))?, + )); + } } } }