From 5e072c0773bb7b8b4d812ebd8db69c3ed44ba51f Mon Sep 17 00:00:00 2001 From: Roman Godmaire Date: Mon, 6 May 2024 07:57:54 -0400 Subject: [PATCH] misc: remove anyhow dependency --- Cargo.lock | 7 ------- Cargo.toml | 1 - src/bin/cli.rs | 3 +-- src/env/io.rs | 3 ++- src/error.rs | 2 ++ src/evaluator.rs | 2 +- src/lib.rs | 2 +- src/node.rs | 2 +- 8 files changed, 8 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 76076f3..278c195 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -60,12 +60,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "anyhow" -version = "1.0.75" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" - [[package]] name = "autocfg" version = "1.1.0" @@ -328,7 +322,6 @@ checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" name = "mute" version = "0.1.0" dependencies = [ - "anyhow", "clap", "rstest", "rustyline", diff --git a/Cargo.toml b/Cargo.toml index 652f1b1..ce2eb80 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,6 @@ name = "mute" path = "src/bin/cli.rs" [dependencies] -anyhow = "1.0.75" clap = { version = "4.5.4", features = ["derive"] } rustyline = "14.0.0" thiserror = "1.0.48" diff --git a/src/bin/cli.rs b/src/bin/cli.rs index b11ae88..0e3a57f 100644 --- a/src/bin/cli.rs +++ b/src/bin/cli.rs @@ -1,8 +1,7 @@ -use anyhow::Result; use clap::{Parser, Subcommand}; use rustyline::{error::ReadlineError, DefaultEditor}; -use mute::{eval, parse, Environment, Node}; +use mute::{eval, parse, Environment, Node, Result}; #[derive(Debug, Parser)] #[clap(version, author, about)] diff --git a/src/env/io.rs b/src/env/io.rs index 40ecbaf..2150f29 100644 --- a/src/env/io.rs +++ b/src/env/io.rs @@ -36,7 +36,8 @@ pub(super) fn io() -> HashMap { let val = args[0].borrow(); if let Node::String(path) = val { - let contents = std::fs::read_to_string(path)?; + let contents = std::fs::read_to_string(path) + .map_err(|err| Error::SystemError(err.to_string()))?; return Ok(Node::String(contents)); } diff --git a/src/error.rs b/src/error.rs index 9dad68a..c206c0b 100644 --- a/src/error.rs +++ b/src/error.rs @@ -23,6 +23,8 @@ pub enum Error { ExpectedString, #[error("expected {0} arguments, got {1}")] MismatchedArgCount(usize, usize), + #[error("system error {0}")] + SystemError(String), #[error("please file a bug report")] Unreachable, diff --git a/src/evaluator.rs b/src/evaluator.rs index 189644c..0134247 100644 --- a/src/evaluator.rs +++ b/src/evaluator.rs @@ -1,6 +1,6 @@ use std::borrow::Borrow; -use anyhow::Result; +use crate::Result; use crate::env::Environment; use crate::error::Error; diff --git a/src/lib.rs b/src/lib.rs index 383caa8..a2f0ef3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,6 +13,6 @@ pub fn parse(input: &str) -> Result> { parser::parse_str(input) } -pub fn eval(env: &Environment, input: Vec) -> anyhow::Result> { +pub fn eval(env: &Environment, input: Vec) -> Result> { evaluator::eval(env, input) } diff --git a/src/node.rs b/src/node.rs index aeba052..8c3bfb3 100644 --- a/src/node.rs +++ b/src/node.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use anyhow::Result; +use crate::Result; use crate::env::Environment;