【Rust】Cargo 创建项目

环境

  • Windows 10
  • Rust 1.54.0

Hello World

根据传统,首先编写一个 Hello World 程序。
参考这里的代码:https://doc.rust-lang.org/cargo/guide/creating-a-new-project.html

Cargo 是 Rust 的包管理器,和 Java 中的 Maven 类似。

创建项目

运行 cargo new hello_world 命令后,得到和 【Rust】Cargo 编译和运行 中一样的目录结构。
并且在此基础上,还生成了 Git 忽略的文件和本地仓库,这里不介绍 Git 相关基础。

C:\Users\jiangbo\work\workspace\rust>cargo new hello_world
     Created binary (application) `hello_world` package

使用 Cargo 运行程序

C:\Users\jiangbo\work\workspace\rust\hello_world>cargo run
   Compiling hello_world v0.1.0 (C:\Users\jiangbo\work\workspace\rust\hello_world)
    Finished dev [unoptimized + debuginfo] target(s) in 1.82s
     Running `target\debug\hello_world.exe`
Hello, world!

总结

使用 Cargo 新建了一个 Hello World 程序。

附录

posted @   jiangbo4444  阅读(796)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!
历史上的今天:
2019-11-30 spring-boot 环境搭建(一)
点击右上角即可分享
微信分享提示