# Rust

# Flag

不显示控制台窗口

  • https://rust-lang.github.io/rfcs/1665-windows-subsystem.html
  • https://learn.microsoft.com/zh-cn/cpp/build/reference/subsystem-specify-subsystem
  • https://stackoverflow.com/questions/74847732/can-you-make-a-windows-desktop-app-in-rust-and-winapi
  • https://stackoverflow.com/questions/29763647/how-to-make-a-program-that-does-not-display-the-console-window
# MSVC
cargo rustc --release -- -Clink-args="/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup"
# GCC 
cargo rustc --release -- -Clink-args="-Wl,--subsystem,windows"

rustup default stable-x86_64-pc-windows-gnu 使gnu(依赖于GNU/MinGW-w64)成为默认工具链

  • Linux
# 设置系统级环境变量
export RUSTUP_DIST_SERVER=https://mirrors.aliyun.com/rustup
export RUSTUP_UPDATE_ROOT=https://mirrors.aliyun.com/rustup/rustup
  • Windows
# 设置系统级环境变量
[Environment]::SetEnvironmentvariable("RUSTUP_DIST_SERVER", "https://mirrors.aliyun.com/rustup", "Machine")
[Environment]::SetEnvironmentvariable("RUSTUP_UPDATE_ROOT", "https://mirrors.aliyun.com/rustup/rustup", "Machine")
Set-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"\
 -Name "RUSTUP_DIST_SERVER" -Value "https://mirrors.aliyun.com/rustup"
Set-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"\
 -Name "RUSTUP_UPDATE_ROOT" -Value "https://mirrors.aliyun.com/rustup/rustup"
# 设置用户级环境变量
New-Item -Path "Env:\RUSTUP_DIST_SERVER" -Value "https://mirrors.aliyun.com/rustup" -Force
New-Item -Path "Env:\RUSTUP_UPDATE_ROOT" -Value "https://mirrors.aliyun.com/rustup/rustup" -Force
New-Item -Path "Env:\" -Name "RUSTUP_DIST_SERVER" -Value "https://mirrors.aliyun.com/rustup" -Force
New-Item -Path "Env:\" -Name "RUSTUP_UPDATE_ROOT" -Value "https://mirrors.aliyun.com/rustup/rustup" -Force
Set-ItemProperty -Path "Registry::HKEY_CURRENT_USER\Environment" -Name "RUSTUP_DIST_SERVER" -Value "https://mirrors.aliyun.com/rustup"
Set-ItemProperty -Path "Registry::HKEY_CURRENT_USER\Environment" -Name "RUSTUP_UPDATE_ROOT" -Value "https://mirrors.aliyun.com/rustup/rustup"
  • Cargo镜像加速
# ~/.cargo/config
# %USERPROFILE%.cargo\config
[source.crates-io]
# 源码地址
registry = "https://github.com/rust-lang/crates.io-index"
# 指定镜像
#replace-with = 'sjtu'
#replace-with = 'ustc'
replace-with = 'rsproxy-sparse'
[source.rsproxy]
registry = "https://rsproxy.cn/crates.io-index"
[source.rsproxy-sparse]
registry = "sparse+https://rsproxy.cn/index/"
[registries.rsproxy]
index = "https://rsproxy.cn/crates.io-index"
# 清华大学
[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
# 中国科学技术大学
[source.ustc]
registry = "https://mirrors.ustc.edu.cn/crates.io-index"
#registry = "git://mirrors.ustc.edu.cn/crates.io-index"
# 上海交通大学
[source.sjtu]
registry = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index"
# rustcc社区
[source.rustcc]
registry = "git://crates.rustcc.cn/crates.io-index"
[source.aliyun]
registry = "https://code.aliyun.com/rustcc/crates.io-index"
[net]
git-fetch-with-cli=true
[http]
check-revoke = false

# 第三方依赖

Cargo子命令