diff --git a/src/formatting.rs b/src/formatting.rs index d229d54..eb097c0 100644 --- a/src/formatting.rs +++ b/src/formatting.rs @@ -49,20 +49,20 @@ pub fn pretty_eval(mut input: String, max_digits: usize) -> Result usize { diff --git a/src/main.rs b/src/main.rs index aace0d9..dc19a05 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,8 +4,7 @@ use std::{ process::ExitCode, }; -mod formatting; -mod nodes; +use tylc as lib; fn main() -> ExitCode { let input = match env::args().skip(1).rev().reduce(|x, a| a + &x) { @@ -17,7 +16,7 @@ fn main() -> ExitCode { } }; - match formatting::pretty_eval(input, 10) { + match lib::formatting::pretty_eval(input, 10) { Ok(s) => println!("{s}"), Err(e) => { diff --git a/src/nodes/parse.rs b/src/nodes/parse.rs index 22a0518..4a20221 100644 --- a/src/nodes/parse.rs +++ b/src/nodes/parse.rs @@ -1,9 +1,9 @@ use core::f64; use std::str::FromStr; -use rug::{Float, float::ParseFloatError, ops::CompleteRound}; +use rug::{Float, float::ParseFloatError}; -use crate::nodes::{Function, Node, Nodes, Operator, PREC}; +use crate::nodes::{Function, Node, Nodes, Operator}; impl Node { fn from_name(s: &str) -> Result { @@ -124,15 +124,10 @@ impl FromStr for Nodes { && !(c == 'e' && filtered_string.chars().nth(i + 1).is_some_and(|c| c == '-')) && !(c == '-' && filtered_string.chars().nth(i - 1).is_some_and(|c| c == 'e')) { - nodes.push(Node::Number( - Float::parse(&filtered_string[start_index..i]) - .map_err(|e| { - Error::NumberParsing( - filtered_string[start_index..i].to_owned(), - e, - ) - })? - .complete(PREC), + nodes.push(Node::from( + Float::parse(&filtered_string[start_index..i]).map_err(|e| { + Error::NumberParsing(filtered_string[start_index..i].to_owned(), e) + })?, )); state = ParsingState::Start; @@ -182,12 +177,10 @@ impl FromStr for Nodes { if matches!(nodes.last(), Some(Node::ParenthesisEnd)) { nodes.push(Node::Operator(Default::default())); } - nodes.push(Node::Number( - Float::parse(&filtered_string[start_index..i]) - .map_err(|e| { - Error::NumberParsing(filtered_string[start_index..i].to_owned(), e) - })? - .complete(PREC), + nodes.push(Node::from( + Float::parse(&filtered_string[start_index..i]).map_err(|e| { + Error::NumberParsing(filtered_string[start_index..i].to_owned(), e) + })?, )); } }