使用python在https://play.rust-lang.org上运行简单的rust代码/
rust-playground的Python项目详细描述
无锈生锈
这是一个用python编写的小工具,它允许您编译简单的 通过http://play.rust-lang.org生锈代码。
安装
您可以从pypi安装这个包。
pip install rust-playground
您还可以在本地克隆此存储库并运行setup.py。
python setup.py install
用法
usage: playground [-h] [--release] [--channel {stable,nightly,beta}]
[--target {llvm-ir,wasm,asm,mir,ast}] [--disable-color]
FILE
Use Python to execute simple Rust code by running it on https://play.rust-
lang.org/
positional arguments:
FILE path to file containing Rust code
optional arguments:
-h, --help show this help message and exit
--release build artifacts in release mode, with optimizations
(default: False)
--channel {stable,nightly,beta}
set Rust channel (default: stable)
--target {llvm-ir,wasm,asm,mir,ast}
build for the target triple (default: ast)
--disable-color disable colors and styles for stderr (default: False)
示例
假设你想快速测试一些生锈代码,但是你现在的机器没有 已安装rust编译器。
// test.rsfnmain(){forxin1..5{println!("{}",x);}}
$ playground test.rs Compiling playground v0.0.1 (file:///playground) Finished dev [unoptimized + debuginfo] target(s) in 2.36s Running `target/debug/playground`1234
它读取您的test.rs
并将其传递给http://play.rust-lang.org进行编译
然后返回终端上的stdout/stderr输出,它看起来非常类似于
$ cargo run
。