3 releases
new 0.0.2 | Dec 11, 2024 |
---|---|
0.0.1 | Dec 6, 2024 |
0.0.0-reserved | Dec 6, 2024 |
#114 in Operating systems
208 downloads per month
9KB
99 lines
cargo-rush
When you're in a rush and don't feel like creating a rust file to test out
small snippets of simple Rust code - simply copy the Rust code to the operating system's clipboard, next, open a terminal and run cargo rush
.
Example 1: main
Step 1: Copy some Rust code to memory
Let's say that we copy the lines below to the clipboard (operating system memory).
fn main() {
let a = 1;
let b = 2;
println!("{} + {} = {}", a, b, a + b);
}
Step 2:
In the terminal:
cargo install cargo-rush
cargo rush
# The command will call `rustc` on whatever is in the clipboard:
1 + 2 = 3
Example 2: Unit Tests
cargo rush
can also run unit tests by using the -t
flag.
Let's say we have the following code on the OS clipboard:
pub fn add(left: u64, right: u64) -> u64 {
left + right
}
fn main() {
println!("Hello world");
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}
Step 1: Copy some Rust code to memory
Step 2: cargo rush -t
Dependencies
~0.4–1.3MB
~25K SLoC