Remove deprecated libivy/bc features
This commit is contained in:
@@ -164,51 +164,12 @@ impl Launcher {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "ivy")]
|
||||
fn calc(s: &str) -> Result<String, String> {
|
||||
libivy::eval(s)
|
||||
}
|
||||
|
||||
#[cfg(feature = "rcalc")]
|
||||
fn calc(s: &str) -> Result<String, String> {
|
||||
rcalc_lib::parse::eval(s, &mut rcalc_lib::parse::CalcState::new())
|
||||
.map(|x| format!("{}", x).to_string())
|
||||
.map_err(|x| format!("{}", x).to_string())
|
||||
}
|
||||
|
||||
#[cfg(feature = "bc")]
|
||||
fn calc(s: &str) -> Result<String, String> {
|
||||
use std::io::Write;
|
||||
let mut child = std::process::Command::new("bc")
|
||||
.stdin(std::process::Stdio::piped())
|
||||
.stdout(std::process::Stdio::piped())
|
||||
.stderr(std::process::Stdio::piped())
|
||||
.arg("--mathlib")
|
||||
.spawn()
|
||||
.map_err(|_| "bc not available".to_string())?;
|
||||
{
|
||||
let stdin = child.stdin.as_mut().unwrap();
|
||||
stdin
|
||||
.write_all(s.as_bytes())
|
||||
.map_err(|_| "unable to write to stdin".to_string())?;
|
||||
stdin
|
||||
.write_all("\n".as_bytes())
|
||||
.map_err(|_| "unable to write to stdin".to_string())?;
|
||||
}
|
||||
let output = child
|
||||
.wait_with_output()
|
||||
.map_err(|_| "unable to run bc".to_string())?;
|
||||
Ok(std::str::from_utf8(&output.stdout)
|
||||
.map_err(|_| "unable to read from bc")?
|
||||
.trim()
|
||||
.to_string())
|
||||
}
|
||||
|
||||
#[cfg(not(any(feature = "ivy", feature = "bc", feature = "rcalc")))]
|
||||
fn calc(_s: &str) -> Result<String, String> {
|
||||
Err("no calculator implementation available".to_string())
|
||||
}
|
||||
|
||||
fn wlcopy(s: &str) -> Result<(), String> {
|
||||
let mut child = std::process::Command::new("wl-copy")
|
||||
.stdin(std::process::Stdio::null())
|
||||
|
||||
Reference in New Issue
Block a user