evalrs-0.0.14 is not a library.
evalrs

Rust code snippet evaluator.
This tiny command evaluates Rust source code which read from the standard input stream.
It can handle extern crate
declaration and has simple caching mechanism.
Documentation
Installation
Execute following command on your terminal:
$ cargo install evalrs
$ evalrs -h
Usage Examples
evalrs
command reads Rust code snippet from the standard input stream and evaluates it:
$ echo 'println!("Hello World!")' | evalrs
Compiling evalrs_temp v0.0.0 (file:///tmp/evalrs_temp.daiPxHtjV2VR)
Finished debug [unoptimized + debuginfo] target(s) in 0.51 secs
Running `target\debug\evalrs_temp.exe`
Hello World!
If target code includes extern crate
declarations,
the latest version of those crates will be downloaded and cached:
$ echo 'extern crate num_cpus; println!("{} CPUs", num_cpus::get())' | evalrs
Updating registry `https://github.com/rust-lang/crates.io-index`
Compiling libc v0.2.18
Compiling num_cpus v1.2.0
Compiling evalrs_temp v0.0.0 (file:///tmp/evalrs_temp.HSRNyVQbM6s3)
Finished debug [unoptimized + debuginfo] target(s) in 0.55 secs
Running `target\debug\evalrs_temp.exe`
4 CPUs
$ echo 'extern crate num_cpus; println!("{} CPUs", num_cpus::get())' | evalrs
Updating registry `https://github.com/rust-lang/crates.io-index`
Compiling evalrs_temp v0.0.0 (file:///tmp/evalrs_temp.4QzdqRG5cY0x)
Finished debug [unoptimized + debuginfo] target(s) in 0.24 secs
Running `target\debug\evalrs_temp.exe`
4 CPUs
If you want to use a specific version of an external crate,
you will be able to specify it at a trailing comment of the extern crate
declaration.
$ evalrs << EOS
extern crate num_cpus; // "1.2.0"
extern crate some_local_crate; // {path = "/path/to/some_local_crate"}
extern crate other_crate; // other-crate = "1"
println!("{} CPUs", num_cpus::get());
EOS
The command wraps input code snippet (except extern crate
declarations) with a main function.
But, if the code has a line which starts with "fn main()",
it will be passed to rustc
command without modification.
$ evalrs << EOS
let a = 1;
let b = 2;
println!("a + b = {}", a + b);
EOS
Compiling evalrs_temp v0.0.0 (file:///tmp/evalrs_temp.gSXTXNaB6o8o)
Finished debug [unoptimized + debuginfo] target(s) in 0.53 secs
Running `target/debug/evalrs_temp`
a + b = 3
$ evalrs << EOS
fn main() {
let a = 1;
let b = 2;
println!("a + b = {}", a + b);
}
EOS
Compiling evalrs_temp v0.0.0 (file:///tmp/evalrs_temp.0kYvCRAj0TWI)
Finished debug [unoptimized + debuginfo] target(s) in 0.20 secs
Running `target/debug/evalrs_temp`
a + b = 3
To support documentation test format,
evalrs
removes "# " string at the beginning of a line.
$ evalrs << EOS
# fn main() {
let a = 1;
let b = 2;
println!("a + b = {}", a + b);
# }
EOS
Compiling evalrs_temp v0.0.0 (file:///tmp/evalrs_temp.0kYvCRAj0TWI)
Finished debug [unoptimized + debuginfo] target(s) in 0.20 secs
Running `target/debug/evalrs_temp`
a + b = 3
Emacs Integration
As an example of integration with Emacs,
you can use quickrun package
to evaluate Rust code in a buffer by using evalrs
command.
First, install quickrun
package as follows:
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
(package-refresh-contents)
(package-install 'quickrun)
Next, add a quickrun command to execute evalrs
:
(quickrun-add-command
"evalrs"
'((:command . "evalrs")
(:exec . ("cat %s | %c %a")))
:default "evalrs")
Now, you can evaluate Rust code snippet in a buffer quickly:
extern crate num_cpus;
println!("You have {} CPU cores", num_cpus::get());