Sophie

Sophie

distrib > Mageia > 6 > x86_64 > by-pkgid > 3dd7afb0e73ef085f903dd0db1dc8c8f > files > 19

cargo-doc-0.22.0-1.mga6.noarch.rpm

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="generator" content="rustdoc">
    <title>Cargo, Rust’s Package Manager</title>

    <link rel="stylesheet" type="text/css" href="stylesheets/normalize.css">
<link rel="stylesheet" type="text/css" href="stylesheets/all.css">
<link rel="stylesheet" type="text/css" href="stylesheets/prism.css">

    <script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<link rel="icon" type="image/x-icon" href="favicon.ico">


</head>
<body class="rustdoc">
    <!--[if lte IE 8]>
    <div class="warning">
        This old browser is unsupported and will most likely display funky
        things.
    </div>
    <![endif]-->

    <a href='https://github.com/rust-lang/cargo' class='fork-me'>
  <img src='images/forkme.png'/>
</a>

<div id="header">
    <a href='https://crates.io' class='logo'>
        <img id="logo" height=100 width=100 src='images/Cargo-Logo-Small.png'/>
    </a>
    <a href="index.html">
        <h1>CARGO</h1>
    </a>

    <div class="search">
        <form action="https://crates.io/search"
              method="GET">
            <input name="q" class="search" placeholder="Search crates" type="text"/>
        </form>
    </div>

    <div class="nav">
        <a href='https://crates.io/crates'>Browse All Crates</a>

        <span class='sep'>|</span>

        <div class="dropdown-container">
            <button class="dropdown">
                Docs
                <span class="arrow"></span>
            </button>
            <!-- Sync this list with
                 https://github.com/rust-lang/crates.io/blob/master/app/templates/application.hbs
                 and with Makefile.in in this repository -->
            <ul id="current-user-links" class="dropdown" data-bindattr-503="503">
                <li><a href='index.html'>Getting Started</a></li>
                <li><a href='guide.html'>Guide</a></li>
                <li><a href='specifying-dependencies.html'>Specifying Dependencies</a></li>
                <li><a href='crates-io.html'>Publishing on crates.io</a></li>
                <li><a href='faq.html'>FAQ</a></li>
                <li><a href='manifest.html'>Cargo.toml Format</a></li>
                <li><a href='build-script.html'>Build Scripts</a></li>
                <li><a href='config.html'>Configuration</a></li>
                <li><a href='pkgid-spec.html'>Package ID specs</a></li>
                <li><a href='environment-variables.html'>Environment Variables</a></li>
                <li><a href='source-replacement.html'>Source Replacement</a></li>
                <li><a href='external-tools.html'>External Tools</a></li>
                <li><a href='policies.html'>Policies</a></li>
            </ul>
        </div>
    </div>
</div>

<main>


    <h1 class="title">Cargo, Rust’s Package Manager</h1>
    
<h1 id='installing' class='section-header'><a href='#installing'>Installing</a></h1>
<p>The easiest way to get Cargo is to get the current stable release of Rust by
using the <code>rustup</code> script:</p>

<pre><code class="language-shell">$ curl -sSf https://static.rust-lang.org/rustup.sh | sh
</code></pre>

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

<p>If you are on Windows, you can directly download the latest 32bit (<a href="https://static.rust-lang.org/dist/rust-1.0.0-i686-pc-windows-gnu.msi">Rust</a>
and <a href="https://static.rust-lang.org/cargo-dist/cargo-nightly-i686-pc-windows-gnu.tar.gz">Cargo</a>) or 64bit (<a href="https://static.rust-lang.org/dist/rust-1.0.0-x86_64-pc-windows-gnu.msi">Rust</a> and <a href="https://static.rust-lang.org/cargo-dist/cargo-nightly-x86_64-pc-windows-gnu.tar.gz">Cargo</a>) Rust stable releases or Cargo nightlies.</p>

<p>Alternatively, you can build Cargo from source.</p>

<h1 id='lets-get-started' class='section-header'><a href='#lets-get-started'>Let’s get started</a></h1>
<p>To start a new project with Cargo, use <code>cargo new</code>:</p>

<pre><code class="language-shell">$ cargo new hello_world --bin
</code></pre>

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

<p>Let’s check out what Cargo has generated for us:</p>

<pre><code class="language-shell">$ cd hello_world
$ tree .
.
├── Cargo.toml
└── src
    └── main.rs

1 directory, 2 files
</code></pre>

<p>This is all we need to get started. First, let’s check out <code>Cargo.toml</code>:</p>

<pre><code class="language-toml">[package]
name = &quot;hello_world&quot;
version = &quot;0.1.0&quot;
authors = [&quot;Your Name &lt;you@example.com&gt;&quot;]
</code></pre>

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

<p>Here’s what’s in <code>src/main.rs</code>:</p>

<pre class="rust rust-example-rendered">
<span class="kw">fn</span> <span class="ident">main</span>() {
    <span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;Hello, world!&quot;</span>);
}</pre>

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

<pre><code class="language-shell">$ cargo build
<span style="font-weight: bold"
class="s1">   Compiling</span> hello_world v0.1.0 (file:///path/to/project/hello_world)</code></pre>

<p>And then run it:</p>

<pre><code class="language-shell">$ ./target/debug/hello_world
Hello, world!
</code></pre>

<p>We can also use <code>cargo run</code> to compile and then run it, all in one step:</p>

<pre><code class="language-shell">$ cargo run
<span style="font-weight: bold"
class="s1">     Fresh</span> hello_world v0.1.0 (file:///path/to/project/hello_world)
<span style="font-weight: bold"
class="s1">   Running</span> `target/hello_world`
Hello, world!</code></pre>

<h1 id='going-further' class='section-header'><a href='#going-further'>Going further</a></h1>
<p>For more details on using Cargo, check out the <a href="guide.html">Cargo Guide</a></p>

    </main>
<footer>
<a href='index.html'>Install</a>
<span class='sep'>|</span>
<a href='index.html'>Getting Started</a>
<span class='sep'>|</span>
<a href='guide.html'>Guide</a>
</footer>

<script type='text/javascript' src='javascripts/prism.js'></script>
<script type='text/javascript' src='javascripts/all.js'></script>


</body>
</html>