Cargo-eval - A cargo plugin to quickly evaluate some Rust source code.

Overview

cargo eval

A cargo plugin to quickly evaluate some Rust source code.

Installation

$ cargo install --git https://github.com/timClicks/cargo-eval.git

Usage

Provide Rust code to be compiled and executed after --:

$ cargo eval -- 1 + 1
> 1 + 1
2

Dependencies can be specified with the -d (--dep) arguments:

$ cargo eval -d fastrand -- 'if fastrand::bool() {
    123 
} else {
    456
}'
> if fastrand::bool() {
    123 
} else {
    456
}
456

Add the -v/--verbose flag to inspect the files from the intermediate crate that is created behind-the-scenes:

$ cargo eval -v -d fastrand -- 'if fastrand::bool() {
    123 
} else {
    456
}'
Cargo.toml
[package]
name = "temp"
version = "0.0.0"
edition = "2021"

[dependencies]
fastrand = "*"

src/main.rs
fn main() -> Result<(), ()> {
    let input = if fastrand::bool() { 123 } else { 456 };
    println!("{}", input);
    Ok(())
}

> if fastrand::bool() {
    123 
} else {
    456
}
123
You might also like...
Code-shape is a tool for extracting definitions from source code files

Code-shape Code-shape is a tool that uses Tree-sitter to extract a shape of code definitions from a source code file. The tool uses the same language

H2O Open Source Kubernetes operator and a command-line tool to ease deployment (and undeployment) of H2O open-source machine learning platform H2O-3 to Kubernetes.
H2O Open Source Kubernetes operator and a command-line tool to ease deployment (and undeployment) of H2O open-source machine learning platform H2O-3 to Kubernetes.

H2O Kubernetes Repository with official tools to aid the deployment of H2O Machine Learning platform to Kubernetes. There are two essential tools to b

Watches over your Cargo project's source.

$ cargo watch Cargo Watch watches over your project's source for changes, and runs Cargo commands when they occur. If you've used nodemon, guard, or e

Dead simple, memoized cargo subcommand to hoist cargo-built binaries into the current working directory, written in Rust.
Dead simple, memoized cargo subcommand to hoist cargo-built binaries into the current working directory, written in Rust.

cargo-hoist Dead simple cargo subcommand to hoist cargo-built binaries into scope. stable Install | User Docs | Crate Docs | Reference | Contributing

Cargo subcommand for running cargo without dev-dependencies.

cargo-no-dev-deps Cargo subcommand for running cargo without dev-dependencies. This is an extraction of the --no-dev-deps flag of cargo-hack to be use

Demo app duplicated in 5 languages (Go/JavaScript/Python/Ruby/Rust) showing how to go from source code to container image using melange+apko

hello-melange-apko 💫 This repo contains an example app duplicated across 5 languages showing how to: Package source code into APKs using melange Buil

Original source code for Practical Rust Projects 2nd ed. by Shing Lyu and Andrew Rzeznik

Apress Source Code This repository accompanies Practical Rust Projects 2nd ed. by Shing Lyu and Andrew Rzeznik (Apress, 2023). Download the files as a

Build some cyber security tools in Rust :crab: :rocket:

here we're trying to write some tools for cyber security in Rust because we don't have enough community for Rust in the cyber security field soo this

Rust port of https://github.com/hunar4321/life_code with some fun features.
Rust port of https://github.com/hunar4321/life_code with some fun features.

Smarticles A Rust port of Brainxyz's Artificial Life simulator with some fun features. A simple program to simulate primitive Artificial Life using si

Owner
Tim McNamara
Tim McNamara
ObfusEval is the benchmarking tool to evaluate the reliability of the code obfuscating transformation.

ObfusEval ObfusEval is the benchmarking tool to evaluate the reliability of the code obfuscating transformation. The following two metrics related the

Software Engineering Lab @ NAIST 4 Dec 15, 2022
This is a tool to evaluate or export code from Markdown files.

Evaluate Markdown This is a tool to evaluate or export code from Markdown files. Why? Because I like writing Markdown files with code snippets (it's g

Balazs Nadasdi 5 Apr 25, 2023
Evaluate performance gains to expect when EVM were to compile hot contracts into machine code

Convert evm bytecode to native machine code and go vroom - just an experiment, probably broken, reach out to [email protected] to contribute / productionize.

Paradigm 105 Aug 1, 2023
RustHopper evaluate grasshopper3d with RhinoCompute from Rust.

RustHopper This is a crate to run grasshopper with RhinoCompute from rust. The input data can be created by entering into main.rs the same Python code

hiron 11 Jan 1, 2023
Evaluate LLM-generated COBOL

COBOLEval: LLM Evaluation for COBOL COBOLEval is a dataset to evaluate the code generation abilities of Large Language Models on the COBOL programming

Bloop AI 22 Jun 26, 2024
A cargo plugin to shrink cargo's output

cargo single-line A simple cargo plugin that shrinks the visible cargo output to a single line (okay, in the best case scenario). In principle, the pl

Denis 5 Oct 30, 2022
Cargo-about - 📜 Cargo plugin to generate list of all licenses for a crate 🦀

?? cargo-about Cargo plugin for generating a license listing for all dependencies of a crate See the book ?? for in-depth documentation. Please Note:

Embark 281 Jan 1, 2023
bevy_scriptum is a a plugin for Bevy that allows you to write some of your game logic in a scripting language

bevy_scriptum is a a plugin for Bevy that allows you to write some of your game logic in a scripting language. Currently, only Rhai is supported, but more languages may be added in the future.

Jarosław Konik 7 Jun 24, 2023
Vim plugin to quickly parse strings into arrays.

butcher Vim plugin to quickly parse strings into arrays. It is painful to write arrays in any programming language, so butcher makes it easy for you.

null 5 Dec 31, 2021
rehype plugin to use tree-sitter to highlight code in pre code blocks

rehype-tree-sitter rehype plugin to use tree-sitter to highlight code in <pre><code> blocks Contents What is this? When should I use this? Install Use

null 5 Jul 25, 2023