Rust-learn-1

18 篇文章 2 订阅

Rust-learn-1

What is Rust

Rust 语言是一种高效、可靠的通用高级语言。其高效不仅限于开发效率,它的执行效率也是令人称赞的,是一种少有的兼顾开发效率和执行效率的语言。

Rust 语言由 Mozilla 开发,最早发布于 2014 年 9 月。Rust 的编译器是在 MIT License 和 Apache License 2.0 双重协议声明下的免费开源软件。截至目前( 2020 年 1 月)最新的编译器版本是 1.41.0。

Why I choose Rust

actually I am a Java | Vue developer , but gradually I do not settle for make softwares , I wanna make some build tools.And I am satisfied with Rust’s advantages!

Install Rust

Rust docs is very particular,we can install it very easy!if you download correctly, you can even not to configure env variables!

address

https://www.rust-lang.org/zh-CN/tools/install

在这里插入图片描述

verify

rustc --version

在这里插入图片描述

get learn docs

we can use rustup docs --books to get the book in your local !
or you can get the translation version from here

build docs in your local

first we should find what we need in GitHub and download zip
在这里插入图片描述
then unzip the package
install vuepress

npm i -g vuepress
npm i -g vue-template-compiler

build the src

vuepress build ./src

open the serve

vuepress dev ./src

vuepress may install slowly , so you should have so patience 😎

result

在这里插入图片描述

VSCode for Rust

we use VSCode as our ‘IDEA’ ,and we need to download these extenions
在这里插入图片描述

Hello World

make a rs file

I make a HelloWorld.rs

code

fn:function
main():like java,c,c++…,the main function,which is the enter of the programe,and it always run first!
println!:focus ! it mean that is a rust macro

fn main(){
  println!("hello world!")
}

build exe

rustc ./HelloWorld.rs

在这里插入图片描述

run exe

./HelloWorld.exe

在这里插入图片描述

What is Cargo

Cargo is Rust’s build system and package manager. Most Rustaceans use Cargo to manage their Rust projects because it can handle many tasks for you, such as building code, downloading dependency libraries, and compiling these libraries

check Cargo

cargo --version

在这里插入图片描述

build project by Cargo

cargo new test_cargo

在这里插入图片描述

a usual project

you will see a project which build by cargo
在这里插入图片描述

check Cargo.toml

[package]
name = "test_cargo"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

build exe by Cargo

cargo build

after compiler you can find a target package
在这里插入图片描述

run

./target/debug/test_cargo.exe

在这里插入图片描述

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值