http://doc.crates.io/

Installing

The easiest way to get Cargo is to get the current stable release of Rust by using the rustup script:

$ curl -sSf https://static.rust-lang.org/rustup.sh | sh

This will get you the current stable release of Rust for your platform along with the latest Cargo.

If you are on Windows, you can directly download the latest 32bit (Rust and Cargo) or 64bit (Rust andCargo) Rust stable releases or Cargo nightlies.

Alternatively, you can build Cargo from source.

Let’s get started

To start a new project with Cargo, use cargo new:

$ cargo new hello_world --bin

We’re passing --bin because we’re making a binary program: if we were making a library, we’d leave it off.

Let’s check out what Cargo has generated for us:

$ cd hello_world
$ tree .
.
├── Cargo.toml
└── src
└── main.rs 1 directory, 2 files

This is all we need to get started. First, let’s check out Cargo.toml:

[package]
name = "hello_world"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]

This is called a manifest, and it contains all of the metadata that Cargo needs to compile your project.

Here’s what’s in src/main.rs:

fn main() {
println!("Hello, world!");
}

Cargo generated a “hello world” for us. Let’s compile it:

$ cargo build
Compiling hello_world v0.1.0 (file:///path/to/project/hello_world)

And then run it:

$ ./target/debug/hello_world
Hello, world!

We can also use cargo run to compile and then run it, all in one step:

$ cargo run
Fresh hello_world v0.1.0 (file:///path/to/project/hello_world)
Running `target/hello_world`
Hello, world!

Going further

For more details on using Cargo, check out the Cargo Guide

Cargo, Rust’s Package Manager的更多相关文章

  1. 你需要知道的包管理器(Package Manager)

    最近我花了一点时间关注了在不同系统之中所用到的包管理器(Package Manager) .最开始的时候,我是在使用Linux操作系统时,对这种工具以及它背后的想法深深迷恋住了:这真是自由的软件世界. ...

  2. 解决VS2015启动时Package manager console崩溃的问题 - Windows PowerShell updated your execution policy successfully, but the setting is overridden by a policy defined at a more specific scope

    安装VS2015,启动以后,Package manager console崩溃,错误信息如下: Windows PowerShell updated your execution policy suc ...

  3. Visual Studio 2015 新建MVC项目 Package Manager Console不能使用 (HRESULT: 0x80131500)

    Visual studio 2015 突然新建不了MVC项目,报出错误: HRESULT: 0x80131500 在折腾了很长时间,最后在Github上看到这样一个贴 地址:https://githu ...

  4. Error: Could not access the Package Manager. Is the system running?

    最近在搭建cordova,android 开发环境,安装android studio之后创建一个demo之后,运行想看一下效果,在运行过程中创建一个虚拟机(arm)的,等了有1分钟左右,再次运行程序, ...

  5. Visual Studio 2010 更新NuGet Package Manager出错解决办法

    在Visual Studio 2010的扩展管理器中发现NuGet Package Manger有最新版本更新提示,选择更新安装提示以下错误信息: 2013/4/25 1:11:48 - Micros ...

  6. Getting and installing the PEAR package manager

    Windows After you have downloaded and installed PHP, you have to manually execute the batch file loc ...

  7. RPM是RedHat Package Manager(RedHat软件包管理工具)

    RPM是RedHat Package Manager(RedHat软件包管理工具)类似Windows里面的“添加/删除程序” rpm 执行安装包二进制包(Binary)以及源代码包(Source)两种 ...

  8. installation - How to install Synaptic Package Manager? - Ask Ubuntu

    installation - How to install Synaptic Package Manager? - Ask Ubuntu How to install Synaptic Package ...

  9. A package manager for Qt

    官网 http://www.qpm.io/ A package manager for Qt 注释:这个网站类似JavaScript的包管理器的网站https://www.npmjs.com/ 都是给 ...

随机推荐

  1. Meld:文件及目录对比工具

    Meld:文件及目录对比工具 http://wowubuntu.com/meld.html http://meld.sourceforge.net/

  2. Sql Server 2014/2012/2008/2005 数据库还原出现 3154错误的解决办法

    在Sql Server  数据库还原出现 3154错误 解决方法1:不要在数据库名字上点右键选择还原,而要是在根目录“数据库”三个字上点右键选择还原,然后再选择数据库,问题便可以解决,如果不行参照方法 ...

  3. Oracle 合并 merger into

    merge into copy_emp1 c  using employees e  on (c.employee_id=e.employee_id)when matched then  update ...

  4. Webstorm和Eclipse常用快捷键

    快捷键配置 点击“File”-> “settings” Webstorm预置了其他编辑器的快捷键配置,可以点击 默认配置-Eclipse的常用快捷键对照表 查找/代替 Webstorm快捷键 E ...

  5. django “如何”系列6:如何部署django

    django满满的快捷方法是的web开发者活的更轻松,但是,如果你不能部署你的站点的话,这是一点用都没有的.不违初衷,部署的简化也是django的一大目标.你可以有几个方法轻松的部署django 由于 ...

  6. oracle11g如何创建数据库

    oracle11g创建数据库的步骤如下:1.按住键盘上Windows键,打开开始菜单,找到Database Configuration Assitant并打开:2.打开数据库配置助手Database ...

  7. 机器学习方法:回归(三):最小角回归Least Angle Regression(LARS),forward stagewise selection

    欢迎转载,转载请注明:本文出自Bin的专栏blog.csdn.net/xbinworld. 希望与志同道合的朋友一起交流,我刚刚设立了了一个技术交流QQ群:433250724,欢迎对算法.技术.应用感 ...

  8. python中的is, ==与对象的相等判断

    在java中,对于两个对象啊a,b,若a==b表示,a和b不仅值相等,而且指向同一内存位置,若仅仅比较值相等,应该用equals.而在python中对应上述两者的是‘is’ 和‘==’. (1) py ...

  9. (翻译)与.NET容器映像保持同步

    原文:https://blogs.msdn.microsoft.com/dotnet/2018/06/18/staying-up-to-date-with-net-container-images/ ...

  10. gvim 编辑器配置

    "关才兼容模式 set nocompatible "模仿快捷键,如:ctrt+A 全选.Ctrl+C复制. Ctrl+V 粘贴等 source $VIMRUNTIME/vimrc_ ...