• w8_274016
  • 30.9KB
  • zip
  • 0
  • VIP专享
  • 0
  • 2022-06-12 06:51
  • rusti-master
  • .gitattributes
  • Cargo.toml
  • Cargo.lock
  • src
  • rusti
  • bin
  • AUTHORS.txt
  • rust-toolchain
  • .travis.yml
  • data
  • tests
  • .gitignore
# Rusti A REPL for the Rust programming language. **The rusti project is deprecated. It is not recommended for regular use.** ## Dependencies On Unix systems, Rusti requires `libncursesw` (`libncurses` on Mac OS). ## Building Rusti builds with Rust nightly, using the Cargo build system. Currently, it **must** be built using a nightly release of the Rust compiler released **no later than 2016-08-01**. The recommended method of installation is to use the following command to [rustup]( rustup install nightly-2016-08-01 ### Installation using Cargo Rusti can be installed directly using Cargo. The following command will download, compile, and install Rusti, placing it in `~/.cargo/bin/` or your operating system equivalent, assuming you haved installed `nightly-2016-08-01` using `rustup`: rustup run nightly-2016-08-01 cargo install --git Then you can run it like this: rustup run nightly-2016-08-01 ~/.cargo/bin/rusti ### Building from a Git clone If using [rustup](, the following command will create an override to use the correct nightly build within the `rusti` source tree: rustup override add nightly-2016-08-01 Build with Cargo: cargo build Run tests: cargo test Run `rusti`: cargo run Install: cargo install ## Usage Running `rusti` gives a prompt that accepts (most) any valid Rust code. If the final statement is an expression, the result will be displayed using the `std::fmt::Debug` trait. This is equivalent to `println!("{:?}", expr);`. ```rust rusti=> println!("Hello, world!"); Hello, world! rusti=> 2 + 2 4 rusti=> (0..5).collect::<Vec<_>>() [0, 1, 2, 3, 4] ``` If any delimiters are left open, `rusti` will continue reading input until they are closed. Only then will the code be executed. ```rust rusti=> fn factorial(n: u32) -> u32 { rusti.> match n { rusti.> 0 => 0, rusti.> 1 => 1, rusti.> n => n * factorial(n - 1), rusti.> } rusti.> } rusti=> factorial(3) 6 rusti=> factorial(4) 24 rusti=> factorial(5) 120 ``` `rusti` can also run a file given on the command line. Note that a `rusti` input file is not quite the same as a typical Rust program. A typical Rust program contains a function named `main`. While a `rusti` program can define functions, no functions will be called automatically. Instead, all statements not within a function body will be executed sequentially, just like interactive mode. ### Loading Crates Loading crates which are part of the standard Rust distribution is as easy as declaring the crate, thusly: ```rust extern crate foo; ``` However, loading a crate that you have compiled yourself requires some extra steps: * First, `rusti` must be able to find the location of compiled crate. You can add a path to its search list using the command line option `-L path`. `rusti` accepts any number of `-L` arguments. * Secondly, `rusti` requires both an `rlib` and a `dylib` version of the compiled crate. If you're building your crate with Cargo, the following command will build the required files for your project's library: cargo rustc --lib -- --crate-type=rlib,dylib If you're building with rustc directly, simply add `--crate-type=rlib,dylib` to the build command to produce the required files. ### Code completion `rusti` provides optional support for code completion using [Racer]( To enable code completion, install Racer as outlined in the [Installation Instructions]( and place the `racer` executable into your `PATH`. ## Commands These are special inputs interpreted by `rusti` that are not directly evaluated as Rust code, though they may operate on Rust code. Commands are invoked by entering a line beginning with `.` or `:`, followed by the name of the command and, perhaps, some text used by the command. Command names may be arbitrarily abbreviated. For example, `.type` may be abbreviated as `.typ`, `.ty`, or `.t`. ### `.block` The `.block` command will run multiple lines of Rust code as one program. To end the command and run all code, input `.` on its own line. ```rust rusti=> .block rusti+> let a = 1; rusti+> let b = a * 2; rusti+> let c = b * 3; rusti+> c rusti+> . 6 ``` Entering `.q` instead will end the command without running code. ### `.exit` The `.exit` command exits the REPL loop. ### `.help` The `.help` command shows usage text for any available commands. ### `.load` The `.load` command evaluates the contents of a named file. ### `.print` The `.print` command will display the value of an expression, using the `std::fmt::Display` trait. This is equivalent to `println!("{}", expr);`. ### `.type` The `.type` command will display the type of an expression without running it. ```rust rusti=> .type 42 42 = i32 rusti=> .t 'x' 'x' = char rusti=> .t "Hello!" "Hello!" = &'static str rusti=> .t (1i32, 2u32) (1i32, 2u32) = (i32, u32) rusti=> fn foo() -> i32 { 1 } rusti=> .t foo foo = fn() -> i32 {foo} rusti=> .t foo() foo() = i32 ``` ## Limitations Currently, Rusti has the following limitations. I hope to fix each of them, but some may prove to be large problems to tackle. * Functions and types are redefined in each round of input. This is inefficient. * `static` items are also redefined in each round of input. This means that the address of a `static` item will change in every round of input and that the values of `mut` items or those with interior mutability will be reset to their initial definition on each round of input. This is bad. * Use of `thread_local!` causes a crash. This is bad. * `let` declarations are local to the input in which they are defined. They cannot be referenced later and are destroyed after that round of input completes its execution. This is inconvenient. * And more! ## License Rusti is distributed under the terms of both the MIT license and the Apache License (Version 2.0). See LICENSE-APACHE and LICENSE-MIT for details.
    • learn-rust, 帮助我学习 Rust 编程语言的项目.zip
      learn-rust, 帮助我学习 Rust 编程语言的项目 通过面试问题学习 Rust这个reposity是我第一次认真尝试学习 Rust的产品。我没有一个特别的probem来处理,所以我使用了工作面试编码问题在互联网上找到。 特别是,"黑了...
    • 用于Rust编程语言的GLFW绑定和包装器。-Rust开发
      glfw-rs Rust编程语言的GLFW绑定和包装。 示例extern crate glfw; 使用glfw :: {Action,Context,Key}; fn main(){le glfw-rs Rust编程语言的GLFW绑定和包装。 示例extern crate glfw; 使用glfw :: {Action,...
    • learning-rust:通过rust编程语言pdf进行工作
      学习锈 这是处理rust文档.pdf的回购
    • rust-koans:Rust编程语言的Koans
      鲁斯特·科恩斯(Rust Koans) 结构 koans按文件划分为多个区域,arrays.rs中覆盖了数组,booleans.rs中引入了布尔值,等等。它们在path_to_enlightenment.rs文件中按顺序显示。 每个koan都会建立您对Rust的知识并...
    • 图书:Rust编程语言
      Rust编程语言 该存储库包含“ The Rust Programming Language”这本书的源代码。 。 您还可以免费在线阅读该书。 请参阅该书随附的最新, 或Rust版本。 请注意,这些版本中的问题可能已经在此存储库中修复,因为...
    • 使用rust编程语言深入研究攻击性安全-抢先体验-Rust开发
      使用锈编程语言深入研究进攻性安全-抢先体验Black Hat Rust-抢先使用Rust编程语言深入研究进攻性安全立即购买本书! 总结无论是在电影中还是在主流媒体中,黑客都经常被浪漫化:他们被描绘成黑魔法师,讨厌的罪犯,...
    • the-book:Rust编程语言代码
      通用编程概念 3.1。变量与可变性 3.2。资料类型 3.3。功能 3.4。评论 3.5。控制流 4.了解所有权 4.1。什么是所有权? 4.2。参考和借阅 4.3。切片类型 5.使用结构来构造相关数据 5.1。定义和实例化结构 5.2。使用...
    • learning-rust:此仓库用于学习rust编程语言
    • Rust编程语言的惯用语intify包装器。-Rust开发
      inotify-rs Rust编程语言的惯用语inotify包装器。 木箱化 inotify-rs Rust编程语言的惯用语inotify包装器。 木箱化 使用std :: env; 使用inotify :: {EventMask,WatchMask,Inotify,}; fn main(){let mut ...
    • GaussDB_100_1.0.1-DATABASE-REDHAT-64bit.tar.gz