Rust最新版安装(v1.78.0+)

news2024/9/24 15:25:51
  • 系统:Windows 11 专业版 23H2
  • rustc:1.78.0

配置环境变量和设置配置文件

新建文件夹“C:\Rust\Rustup”和“C:\Rust\Cargo”。【以管理员身份运行】打开CMD

在这里插入图片描述

设置系统环境变量,如下设置RUSTUP_DIST_SERVER,其余同理

C:\Windows\System32>setx RUSTUP_DIST_SERVER http://mirrors.ustc.edu.cn/rust-static

成功: 指定的值已得到保存。
setx RUSTUP_DIST_SERVER http://mirrors.ustc.edu.cn/rust-static
setx RUSTUP_UPDATE_ROOT http://mirrors.ustc.edu.cn/rust-static/rustup
setx RUSTUP_HOME C:\Rust\Rustup
setx CARGO_HOME C:\Rust\Cargo

【以管理员身份运行】重新打开CMD,用set命令查看环境变量配置情况。

C:\Windows\System32>set
...
CARGO_HOME=C:\Rust\Cargo
...
RUSTUP_DIST_SERVER=http://mirrors.ustc.edu.cn/rust-static
RUSTUP_HOME=C:\Rust\Rustup
RUSTUP_UPDATE_ROOT=http://mirrors.ustc.edu.cn/rust-static/rustup
...

新建文件"C:\Rust\Cargo\config",config无需后缀

在这里插入图片描述

config文件内容如下

[source.crates-io]
registry = "https://github.com/rust-lang/crates.io-index"
# 指定镜像
replace-with = 'ustc' # 如:tuna、sjtu、ustc,或者 rustcc
# 注:以下源配置一个即可,无需全部
# 中国科学技术大学
[source.ustc]
registry = "https://mirrors.ustc.edu.cn/crates.io-index"
# 上海交通大学
[source.sjtu]
registry = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index/"
# 清华大学
[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
# rustcc社区
[source.rustcc]
registry = "https://code.aliyun.com/rustcc/crates.io-index.git"

开始安装rustup-init

下载“rustup-init.exe”,可以使用官网下载地址,并打开

在这里插入图片描述

Rust Visual C++ prerequisites

Rust requires a linker and Windows API libraries but they don't seem to be
available.

These components can be acquired through a Visual Studio installer.

1) Quick install via the Visual Studio Community installer
   (free for individuals, academic uses, and open source).

2) Manually install the prerequisites
   (for enterprise and advanced users).

3) Don't install the prerequisites
   (if you're targeting the GNU ABI).

>1

info: downloading Visual Studio installer
  3.8 MiB /   3.8 MiB (100 %) 867.7 KiB/s in  7s ETA:  0s
info: running the Visual Studio install
info: rustup will continue once Visual Studio installation is complete

安装程序会自动下载Visual Studio installer,【继续】

在这里插入图片描述

全部勾选,【安装】

在这里插入图片描述

在这里插入图片描述

【关闭】

在这里插入图片描述

Welcome to Rust!

This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.

Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:

  C:\Rust\Rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory is located at:

  C:\Rust\Cargo

This can be modified with the CARGO_HOME environment variable.

The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:

  C:\Rust\Cargo\bin

This path will then be added to your PATH environment variable by
modifying the HKEY_CURRENT_USER/Environment/PATH registry key.

You can uninstall at any time with rustup self uninstall and
these changes will be reverted.

Current installation options:


   default host triple: x86_64-pc-windows-msvc
     default toolchain: stable (default)
               profile: default
  modify PATH variable: yes

1) Proceed with standard installation (default - just press enter)
2) Customize installation
3) Cancel installation
>1

info: profile set to 'default'
info: default host triple is x86_64-pc-windows-msvc
info: syncing channel updates for 'stable-x86_64-pc-windows-msvc'
info: latest update on 2024-05-02, rust version 1.78.0 (9b00956e5 2024-04-29)
info: downloading component 'cargo'
  6.2 MiB /   6.2 MiB (100 %)   1.8 MiB/s in  3s ETA:  0s
info: downloading component 'clippy'
  2.1 MiB /   2.1 MiB (100 %)   1.6 MiB/s in  1s ETA:  0s
info: downloading component 'rust-docs'
 15.1 MiB /  15.1 MiB (100 %)   1.7 MiB/s in  8s ETA:  0s
info: downloading component 'rust-std'
 18.0 MiB /  18.0 MiB (100 %)   1.7 MiB/s in 10s ETA:  0s
info: downloading component 'rustc'
 57.4 MiB /  57.4 MiB (100 %)   1.7 MiB/s in 34s ETA:  0s
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
 15.1 MiB /  15.1 MiB (100 %)   1.6 MiB/s in 14s ETA:  0s
info: installing component 'rust-std'
 18.0 MiB /  18.0 MiB (100 %)  13.4 MiB/s in  1s ETA:  0s
info: installing component 'rustc'
 57.4 MiB /  57.4 MiB (100 %)  16.9 MiB/s in  3s ETA:  0s
info: installing component 'rustfmt'
info: default toolchain set to 'stable-x86_64-pc-windows-msvc'

  stable-x86_64-pc-windows-msvc installed - rustc 1.78.0 (9b00956e5 2024-04-29)


Rust is installed now. Great!

To get started you may need to restart your current shell.
This would reload its PATH environment variable to include
Cargo's bin directory (C:\Rust\Cargo\bin).

Press the Enter key to continue.

验证安装

安装完成,文件夹“C:\Rust\Rustup”和“C:\Rust\Cargo”新增很多文件。CMD运行:

C:\Users\sywq6>rustc -V
rustc 1.78.0 (9b00956e5 2024-04-29)

使用Visual Studio Code开发调试

创建新项目

下载VS Code,下载地址为:Download Visual Studio Code - Mac, Linux, Windows

在这里插入图片描述

新建文件夹rust_demo,打开这个文件夹,新建终端,新建项目

cargo new rust_demo

在这里插入图片描述

修改main.rs

fn main() { 
    let number = 3; 
 
    if number < 5 { 
        println!("condition was true"); 
    } else { 
        println!("condition was false"); 
    } 
}

运行项目

cd .\rust_demo\
cargo run

在这里插入图片描述

调试代码

打开Visual Studio Code插件市场,下载三个插件

  • rust-analyzer
  • CodeLLDB
  • Code Runner

在这里插入图片描述

设置断点,点击【Debug】,开始调试Rust代码

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1706285.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

中国教育 AI 产品正在成为百万美国学生的辅导老师;李飞飞:大模型不存在主观感觉能力丨 RTE 开发者日报 Vol.213

开发者朋友们大家好&#xff1a; 这里是 「RTE 开发者日报」 &#xff0c;每天和大家一起看新闻、聊八卦。 我们的社区编辑团队会整理分享 RTE&#xff08;Real-Time Engagement&#xff09; 领域内「有话题的新闻」、「有态度的观点」、「有意思的数据」、「有思考的文章」、…

编程5年的老哥说:我代码里从来不用锁,谁爱...

技多不压身&#xff01; 大家好&#xff0c;我是 javapub。 今天一个朋友找我吐槽&#xff0c;说自己平时在工作中几乎用不到需要上锁的场景&#xff0c;就算有也只是并发很小、或者直接从有业务设计上就规避掉了。但一到面试&#xff0c;都是各种锁题&#xff0c;很头疼。 面…

YYDS!哈工大博士PyTorch笔记火了!!

Pytorch是目前常用的深度学习框架之一&#xff0c;它凭借着对初学者的友好性、灵活性&#xff0c;发展迅猛&#xff0c;它深受学生党的喜爱&#xff0c;我本人也是使用的Pytorch框架。 比起 TF 的框架环境配置不兼容&#xff0c;和 Keras 由于高度封装造成的不灵活&#xff0c…

三、Ollama导入大模型(.Net8+SemanticKernel+Ollama)本地运行自己的大模型

Ollama导入大模型 一、导入Ollama大模型1、使用run命令2、使用Modelfile方式 二、导入自定义大模型&#xff08;Ollama官网以外的大模型&#xff09;三、使用OpenWebUI导入大模型 Ollama可以导入官方提供的大模型&#xff0c;也可以导入huggingface上的自定义大模型&#xff08…

以太坊现货ETF获批:引发ETH价格暴涨,市场热议达到高潮

2024年5月24日&#xff0c;北京时间&#xff0c;以太坊现货ETF正式获得美国证券交易委员会&#xff08;SEC&#xff09;的批准&#xff0c;成为继比特币之后&#xff0c;美国主权政府承认的又一加密货币基金产品。这一意外的利好消息引发了加密货币市场的狂欢&#xff0c;以太坊…

东软的第三个研发基地,为什么选择了武汉?

继沈阳、大连之后&#xff0c;东软集团在国内打造的第三个研发基地——武汉东软软件园&#xff0c;于2024年5月25日正式开园。 “占地面积158亩、建筑面积14万余平方米的武汉东软软件园&#xff0c;从开工到竣工仅仅用了18个月的时间。这样的建设速度&#xff0c;充分体现了武汉…

香橙派Kunpeng Pro性能测评:高效能小型服务器开发板的全面体验

香橙派 Kunpeng Pro 是一款面向开发者和教育市场的高性能单板计算机&#xff0c;其搭载了鲲鹏处理器&#xff0c;可提供 8TOPS INT8 计算能力&#xff0c;提供了 8GB 和 16GB 两种内存版本&#xff0c;开发板结合了鲲鹏全栈根技术&#xff0c;全面使能高校计算机系统教学和原生…

3D Web轻量化平台HOOPS Web Platform在数字工厂中的应用实例

今天我们来聊聊HOOPS工具对大型数据的处理和可视化管理。这里是一个数字工厂的仪表盘展示&#xff0c;您可以在仪表盘上看到包括工厂的能源消耗、计划产量等数据信息&#xff0c;以及各种制造机器的生产量。 HOOPS中文网http://techsoft3d.evget.com/ 我们的HOOPS工具&#xf…

window.location.search取不到值

window.location.search window.location.search没有值的原因&#xff1a; URL中使用了 hash &#xff08;指URL中带有#符号&#xff09;,导致URL后面携带的参数被location.hash截取走了&#xff0c;你再使用window.location.search得到的就是空值 打印 window.location 其实…

网络侦察技术

网络侦察技术 收集的信息网络侦察步骤搜索引擎检索命令bing搜索引擎Baidu搜索引擎Shodan钟馗之眼(zoomeye) whois数据库&#xff1a;信息宝库查询注册资料 域名系统网络拓扑社交网络跨域拓展攻击 其它侦察手段社会工程学社会工程学常见形式Web网站查询 其它非技术侦察手段总结网…

通过代码重用攻击绕过现代XSS防御

XSS已有近二十年的历史了&#xff0c;但它仍然是Web上最常见的漏洞之一。因此&#xff0c;已经发展了许多机制来减轻漏洞的影响。我经常会误以为这些机制可以作为针对XSS的保护。今天&#xff0c;我们将了解为什么情况并非如此。我们将在代码重用攻击领域探索一种相对较新的技术…

5.基于python的scRNA-seq细胞状态分析-细胞扰动

参考&#xff1a; [1] https://github.com/Starlitnightly/single_cell_tutorial [2] https://github.com/theislab/single-cell-best-practices 目录 背景识别受扰动影响最大的细胞类型预测细胞的扰动响应构建模拟数据集构建scGEN 背景 前面学习了不同处理条件下的基因差异表…

QGis3.34.5工具软件保存样式,软件无反应问题

在使用QGis软件保存SLD样式的时候&#xff0c;每次保存样式&#xff0c;软件都进入无反应状态&#xff0c;导致无法生成样式文件 百度中多次查询问题点&#xff0c;终未能在在3.34.5这个版本上解决问题。 考虑到可能是软件本身问题&#xff0c;于是删除了3.34.5这个版本&#x…

报修新选择:一款软件搞定所有维修问题

数字化、智能化时代发展迅速&#xff0c;各类便捷、智能化软件应用已经深入到我们生活和工作的方方面面。尤其是在企业或学校的设备管理中&#xff0c;报修维修工作一直是一个重要环节。传统的报修方式&#xff0c;如电话报修、填写纸质报修单等&#xff0c;已经无法满足现代高…

Pytorch索引、切片、连接

文章目录 1.torch.cat()2.torch.column_stack()3.torch.gather()4.torch.hstack()5.torch.vstack()6.torch.index_select()7.torch.masked_select()8.torch.reshape9.torch.stack()10.torch.where()11.torch.tile()12.torch.take() 1.torch.cat() torch.cat() 是 PyTorch 库中的…

联想凌拓 NetApp AFF C250 全闪存存储助力丰田合成打造数据新“引擎”

联想凌拓 NetApp AFF C250全闪存存储助力丰田合成打造数据新“引擎” 丰田合成&#xff08;张家港&#xff09;科技有限公司&#xff08;以下简称“丰田合成”&#xff09;于2003年12月成立&#xff0c;坐落在中国江苏省张家港市保税区中华路113号&#xff0c;是日本丰田合成株…

亚马逊自养号与机刷有何区别?

在亚马逊这一全球电商巨头中&#xff0c;买家评价的重要性如同指南针般引领着消费者的购买决策。在购买前&#xff0c;消费者们往往会驻足查看产品的评论&#xff0c;仔细比较不同产品的买家口碑&#xff0c;以确保自己的选择既明智又满意。因此&#xff0c;测评成为了各大电商…

空间转录组数据的意义

10X空间转录组Visium学习笔记&#xff08;三&#xff09;跑通Visium全流程记录 | 码农家园 (codenong.com) 这两个的区别是&#xff1a;一个是像素的位置信息&#xff0c;一个是阵列的位置信息

百度百科个人词条怎么这么难通过?

百度百科作为国内最具影响力的知识平台&#xff0c;个人词条的通过率却让很多人感到困惑。为什么我的个人词条总是难以通过&#xff1f;伯乐网络传媒给大家揭秘百度百科个人词条审核的难点&#xff0c;并提供相应的对策。 一、百度百科词条难以通过的原因分析 1. 内容不符合审…

小动物单通道麻醉机、多通道麻醉机

ZL-04A-5多通道小动物麻醉机采用英国进口的挥发罐体&#xff0c;国内组装而成&#xff0c;产品输出气体稳定。多通道小动物麻醉机无需氧气瓶&#xff0c;自带空气输出机&#xff0c;小动物麻醉机对氧气浓度有要求可以选配氧气输出机。 详情介绍&#xff1a; 产品特点&#xf…