diff --git a/src/function.rs b/src/function.rs index f67b85a..bb9b56e 100644 --- a/src/function.rs +++ b/src/function.rs @@ -311,7 +311,7 @@ impl FunctionEntry { self } - pub fn get_derivative_str(&self) -> &str { self.function.get_derivative_str() } + pub fn get_derivative_str(&self) -> String { self.function.get_derivative_str() } } #[test] diff --git a/src/parsing.rs b/src/parsing.rs index eab5078..77ea0f6 100644 --- a/src/parsing.rs +++ b/src/parsing.rs @@ -19,7 +19,9 @@ impl BackingFunction { } } - pub fn get_derivative_str(&self) -> &str { self.derivative_1.unparse() } // TODO: maybe pretty-ify the output here? idk, it's pretty ugly + pub fn get_derivative_str(&self) -> String { + String::from(self.derivative_1.unparse()).replace("{x}", "x") + } pub fn get(&self, x: f64) -> f64 { self.function.eval(&[x]).unwrap_or(f64::NAN) }