介绍Rust

栏目: 编程语言 · Rust · 发布时间: 7年前

内容简介:mac上

What is rust-lang

Rust 是一个由Mozilla主导开发的通用的、编译型计算机语言。它的设计准则为“安全,并发,实用”,支持函数式,并发式,过程式以及面向对象的编程风格。

安装

mac上

brew install rust

Linux上

curl https://sh.rustup.rs -sSf | sh

查看版本

rustc -V

rust 起手式

//hi.rs
fn main(){
  println!("hello rust")
}

编译执行

rustc hi.rs #编译出 hi执行文件
./hi #执行

分别看下 C / Golang / Rust 编译出的文件大小

61B   hi-c.c
8.3K  hi-c

72B   hi-go.go
2.0M  hi-go

39B   hi.rs
477K  hi-rust

rust的477K 比C的8K大不少啊, 但 go 足足有2M.

Rust Cargo

rust Car-go 是用来辅助管理 Rust工程的工具。

跟npm pip bundler作用一样, 当然 Cargo没有 C/C++的automake 、cmake、qmake带来的那种尴尬.

cargo 是否安装好了 cargo --version

新建个项目

cargo new hyper  --bin 

hyper
  ├── Cargo.toml
  └── src
       └── main.rs

编译

cargo build

├── Cargo.lock
├── Cargo.toml
├── src
│   └── main.rs
└── target
    └── debug
        ├── build
        ├── deps
        ├── examples
        ├── hyper
        ├── hyper.d
        ├── incremental
        └── native

执行

cargo run

参考:

http://wiki.jikexueyuan.com/project/rust-primer/cargo-projects-manager/cargo-projects-manager.html


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

The Art of Computer Programming, Volumes 1-3 Boxed Set

The Art of Computer Programming, Volumes 1-3 Boxed Set

Donald E. Knuth / Addison-Wesley Professional / 1998-10-15 / USD 199.99

This multivolume work is widely recognized as the definitive description of classical computer science. The first three volumes have for decades been an invaluable resource in programming theory and p......一起来看看 《The Art of Computer Programming, Volumes 1-3 Boxed Set》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

随机密码生成器
随机密码生成器

多种字符组合密码

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码