【Rust】Rust入门(一)

前言

    我对我不会的语言都有一定的好奇心,为啥跑去学Rust,因为rust与前端结合比较紧密,并且deno也是rust写的。

安装

    https://www.rust-lang.org/tools/install 上面地址进行安装,选默认即可。 安装完毕后使用命令行输入
rustc --version
    有响应表示成功。

hello world

    编写文件,main.rs:
fn main() {
          
   
    println!("Hello, world!");
}
    如果出现下面报错,请在第一个网址里安装vs cpp build。
error: linker `link.exe` not found
  |
  = note: 系统找不到指定的文件。 (os error 2)

note: the msvc targets depend on the msvc linker but `link.exe` was not found

note: please ensure that VS 2013, VS 2015, VS 2017 or VS 2019 was installed with the Visual C++ option

error: aborting due to previous error
    之后执行
rutstc main.rs
    则会出现main.pdb main.exe文件 直接执行exe文件即可看见helloworld

官网

    https://www.rust-lang.org/ https://crates.io/
经验分享 程序员 微信小程序 职场和发展