当前位置: 首页 > news >正文

做网站要求什么条件网站建设南京

做网站要求什么条件,网站建设南京,沈阳营商环境建设局网站,成都网站建设门户文章目录 关于 Cargo构建项目创建工程编译运行buildclean 管理依赖添加依赖updatecheck计时 manual rust 安装可参考:https://blog.csdn.net/lovechris00/article/details/124808034 关于 Cargo Cargo 官方文档 : https://doc.rust-lang.org/cargo/crat…

在这里插入图片描述

文章目录

    • 关于 Cargo
    • 构建项目
      • 创建工程
      • 编译运行
      • build
      • clean
    • 管理依赖
      • 添加依赖
      • update
      • check
      • 计时
    • manual


rust 安装可参考:https://blog.csdn.net/lovechris00/article/details/124808034


关于 Cargo

  • Cargo 官方文档 : https://doc.rust-lang.org/cargo/
  • crates : https://crates.io

Cargo is the Rust package manager.
Cargo downloads your Rust package’s dependencies, compiles your packages, makes distributable packages, and uploads them to crates.io, the Rust community’s package registry.


构建项目

创建工程

cargo new world_hello

目录结构如下

$ tree
.
├── Cargo.toml
└── src└── main.rs1 directory, 2 files

  • Cargo.toml 为 Rust 的清单文件。其中包含了项目的元数据和依赖库。
  • src/main.rs 为编写应用代码的地方。

编译运行

cargo run

   Compiling world_hello v0.1.0 (/Users/user/Documents/code/scode1/rust/world_hello)Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.95sRunning `target/debug/world_hello`
Hello, world!

会产生编译文件

$ tree -L 3
.
├── Cargo.lock
├── Cargo.toml
├── src
│   └── main.rs
└── target├── CACHEDIR.TAG└── debug├── build├── deps├── examples├── incremental├── world_hello└── world_hello.d

运行 build/run 命令会创建一个新文件 Cargo.lock,该文件记录了本地所用依赖库的精确版本。


build

使用 run 就会自动build,但有时候我们可以只使用 build

cargo build
  • 会生成 debug 文件夹:world_hello/target/debug
  • 将 debug 文件夹删掉,再次 build 会产生新的 debug 文件夹;
  • 如果原文件没修改,build 后,debug 的内容可能不会更新。

clean

cargo clean

debug 等文件夹会被删掉

$ cargo cleanRemoved 119 files, 11.4MiB total
$ tree
.
├── Cargo.lock
├── Cargo.toml
└── src└── main.rs1 directory, 3 files

管理依赖

创建项目会自动生成 Cargo.toml 文件
原始内容如下:

[package]
name = "world_hello"
version = "0.1.0"
edition = "2021"[dependencies]

添加依赖

在 Rust 中,我们通常把包称作crates
你可以在 crates 库搜索依赖:https://crates.io/crates/rand

这里以添加 rand 为例,添加在 [dependencies] 下方

...
[dependencies]
rand = "0.3.14"

再次 build

$ cargo buildUpdating crates.io indexDownloaded rand v0.3.23Downloaded rand v0.4.6Downloaded libc v0.2.154Downloaded 3 crates (831.0 KB) in 1.22sCompiling libc v0.2.154Compiling rand v0.4.6Compiling rand v0.3.23Compiling world_hello v0.1.0 (/Users/user/Documents/code/scode1/rust/world_hello)Finished `dev` profile [unoptimized + debuginfo] target(s) in 4.11s

查看文件结构
多出了 rand 相关内容

$ tree
.
├── Cargo.lock
├── Cargo.toml
├── src
│   └── main.rs
└── target├── CACHEDIR.TAG└── debug├── build│   ├── libc-f94129358965b880│   │   ├── invoked.timestamp│   │   ├── out│   │   ├── output│   │   ├── root-output│   │   └── stderr│   └── libc-fc8c71922db79826│       ├── build-script-build│       ├── build_script_build-fc8c71922db79826│       └── build_script_build-fc8c71922db79826.d├── deps│   ├── libc-2cd8d736a65e3bdc.d│   ├── libc-2cd8d736a65e3bdc.libc.844209738d3bf612-cgu.0.rcgu.o│   ├── liblibc-2cd8d736a65e3bdc.rlib│   ├── liblibc-2cd8d736a65e3bdc.rmeta│   ├── librand-51e82a279537c372.rlib│   ├── librand-51e82a279537c372.rmeta│   ├── librand-76148f2644fb6b76.rlib│   ├── librand-76148f2644fb6b76.rmeta│   ├── rand-51e82a279537c372.d│   ├── ...│   ├── rand-76148f2644fb6b76.rand.46a886c6f1f6cb04-cgu.4.rcgu.o│   ├── world_hello-7dfffed2f60728f0│   ├── ...│   └── world_hello-ffc760ff065d95f4.rvrclgiszz772pw.rcgu.o├── examples├── incremental│   ├── world_hello-2gr5fivx8ev9t│   │   ├── s-gvxy0ymbb9-azi538-5zea3fzl7hz9mcsbpmuo9lnu2│   │   │   ├── 2ao7q67wh7pwb6v2.o│   │   │   ├── ...│   │   │   └── work-products.bin│   │   └── s-gvxy0ymbb9-azi538.lock│   └── world_hello-32qpckyi3s6et│       ├── s-gvxxyb5ewl-1g1nr9k-5ewriqusvpjsrgth3731ddhf3│       │   ├── 2jcl4b6uedw0auwo.o│       │   ├── ...│       │   ├── rvrclgiszz772pw.o│       │   └── work-products.bin│       └── s-gvxxyb5ewl-1g1nr9k.lock├── world_hello└── world_hello.d14 directories, 65 files

update

更新所有依赖

cargo update

更新指定库

cargo update -p rand

check

查看对目录进行了哪些更改

修改内容 按 倒序排序

运行 check 之前,cargo clean 清理目录

$ cargo checkChecking libc v0.2.154Checking rand v0.4.6Checking rand v0.3.23Checking world_hello v0.1.0 (/Users/user/Documents/code/scode1/rust/world_hello)Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.94s

计时

查看编译时间

time cargo build

manual

cargo help

Rust’s package manager

Usage: cargo [+toolchain] [OPTIONS] [COMMAND]
cargo [+toolchain] [OPTIONS] -Zscript <MANIFEST_RS> [ARGS]…


Options:

  • -V, --version, Print version info and exit
    • -list, List installed commands
    • -explain <CODE, Provide a detailed explanation of a rustc error message
  • -v, --verbose... , Use verbose output (-vv very verbose/build.rs output)
  • -q, --quiet, Do not print cargo log messages
    • -color <WHEN, Coloring: auto, always, never
  • -C <DIRECTORY, Change to DIRECTORY before doing anything
    , , (nightly-only)
    • -frozen, Require Cargo.lock and cache are up to date
    • -locked, Require Cargo.lock is up to date
    • -offline, Run without accessing the network
    • -config <KEY=VALUE, Override a configuration value
  • -Z <FLAG>, Unstable (nightly-only) flags to Cargo, see cargo -Z help for details
  • -h, --help, Print help

Commands:

  • build, b : Compile the current package
  • check, c : Analyze the current package and report errors, but don’t build object files
  • clean: Remove the target directory
  • doc, d, Build this package’s and its dependencies’ documentation
  • new, : Create a new cargo package
  • init: Create a new cargo package in an existing directory
  • add, : Add dependencies to a manifest file
  • remove, Remove dependencies from a manifest file
  • run, r, Run a binary or example of the local package
  • test, t : Run the tests
  • bench: Run the benchmarks
  • update, Update dependencies listed in Cargo.lock
  • search, Search registry for crates
  • publish : Package and upload this package to the registry
  • install : Install a Rust binary
  • uninstall Uninstall a Rust binary
  • … : See all commands with --list

See cargo help <command> for more information on a specific command.


写完以上后,发现这个官方教程就挺好,参考:
<https://www.rust-lang.org/zh-CN/learn >


伊织 2024-05-07(二)

http://www.yayakq.cn/news/957310/

相关文章:

  • 免费建网站的天津百度快速排名优化
  • 建设校园门户网站信息意义wordpress主题插件
  • 新网站建设验收论坛网站开发外文文献
  • 网站单向外链推广工具网站开发浏览器不支持flash
  • 网站开发及维护费用网站是由哪些组成
  • 怎样用ps做网站首页图片服务器放多个网站
  • 河北省建设厅网站查询湖州站内优化seo公司
  • 东莞专业做淘宝网站做spa会所网站
  • 前端 国外 网站网络营销推广的方法有哪些
  • 网站设计怎么做明信片网站上传后打不开
  • 正规的环保行业网站开发网站设计要点 优帮云
  • 做网站片头的软件龙华网站建设方案书例文
  • 蛋糕网站内容规划wordpress注册后绑定qq邮箱
  • 网站设计为什么要域名做网站公司合同
  • 青色系 网站免费的网页入口
  • 通王网站内容管理系统美橙互联建站
  • 易用的做网站软件网络营销为导向的企业网站
  • 代理备案网站十大装修公司
  • 友情链接交换网汕头网站时优化
  • 用ps怎么做网站导航条怎么做企业做网站的流程
  • 那些网站是php开发的阿里巴巴网站是怎么做的
  • 网站建设极地网贵州建设考试网站
  • 怎么制作网站店铺江苏省建设执业中心网站
  • 网站备案幕布多少钱网络规划设计师 用途
  • 温州网站建设培训班素材网站有哪些
  • 广州市网站建设需要审批东莞常平招聘网最新招聘信息
  • 网站开发前端和后端技术wordpress 3.8主题
  • 网站不能上传图片开发一个app大概要多少钱
  • 中山市城乡和住房建设局网站网站如何添加统计代码是什么意思
  • html5网站设计欣赏wordpress首页显示推荐标志