summaryrefslogtreecommitdiff
path: root/crates/cli
diff options
context:
space:
mode:
Diffstat (limited to 'crates/cli')
-rw-r--r--crates/cli/src/args.rs6
-rw-r--r--crates/cli/src/bin.rs10
2 files changed, 8 insertions, 8 deletions
diff --git a/crates/cli/src/args.rs b/crates/cli/src/args.rs
index 3959572..96c3605 100644
--- a/crates/cli/src/args.rs
+++ b/crates/cli/src/args.rs
@@ -5,7 +5,7 @@ use tinywasm::types::WasmValue;
pub struct WasmArg(WasmValue);
pub fn to_wasm_args(args: Vec<WasmArg>) -> Vec<WasmValue> {
- args.into_iter().map(|a| a.into()).collect()
+ args.into_iter().map(Into::into).collect()
}
impl From<WasmArg> for WasmValue {
@@ -18,14 +18,14 @@ impl FromStr for WasmArg {
type Err = String;
fn from_str(s: &str) -> std::prelude::v1::Result<Self, Self::Err> {
let [ty, val]: [&str; 2] =
- s.split(':').collect::<Vec<_>>().try_into().map_err(|e| format!("invalid arguments: {:?}", e))?;
+ s.split(':').collect::<Vec<_>>().try_into().map_err(|e| format!("invalid arguments: {e:?}"))?;
let arg: WasmValue = match ty {
"i32" => val.parse::<i32>().map_err(|e| format!("invalid argument value for i32: {e:?}"))?.into(),
"i64" => val.parse::<i64>().map_err(|e| format!("invalid argument value for i64: {e:?}"))?.into(),
"f32" => val.parse::<f32>().map_err(|e| format!("invalid argument value for f32: {e:?}"))?.into(),
"f64" => val.parse::<f64>().map_err(|e| format!("invalid argument value for f64: {e:?}"))?.into(),
- t => return Err(format!("Invalid arg type: {}", t)),
+ t => return Err(format!("Invalid arg type: {t}")),
};
Ok(WasmArg(arg))
diff --git a/crates/cli/src/bin.rs b/crates/cli/src/bin.rs
index 15e3fdc..6efbba1 100644
--- a/crates/cli/src/bin.rs
+++ b/crates/cli/src/bin.rs
@@ -14,7 +14,7 @@ mod util;
mod wat;
#[derive(FromArgs)]
-/// TinyWasm CLI
+/// `TinyWasm` CLI
struct TinyWasmCli {
#[argh(subcommand)]
nested: TinyWasmSubcommand,
@@ -40,7 +40,7 @@ impl FromStr for Engine {
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"main" => Ok(Self::Main),
- _ => Err(format!("unknown engine: {}", s)),
+ _ => Err(format!("unknown engine: {s}")),
}
}
}
@@ -98,19 +98,19 @@ fn main() -> Result<()> {
};
match engine {
- Engine::Main => run(module, func, to_wasm_args(args)),
+ Engine::Main => run(module, func, &to_wasm_args(args)),
}
}
}
}
-fn run(module: Module, func: Option<String>, args: Vec<WasmValue>) -> Result<()> {
+fn run(module: Module, func: Option<String>, args: &[WasmValue]) -> Result<()> {
let mut store = tinywasm::Store::default();
let instance = module.instantiate(&mut store, None)?;
if let Some(func) = func {
let func = instance.exported_func_untyped(&store, &func)?;
- let res = func.call(&mut store, &args)?;
+ let res = func.call(&mut store, args)?;
info!("{res:?}");
}