Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
rust
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
orestis.malaspin
rust
Commits
d37e3342
There was a problem fetching the pipeline summary.
Commit
d37e3342
authored
7 years ago
by
orestis.malaspin
Browse files
Options
Downloads
Patches
Plain Diff
installation mise a jour
parent
fb67904c
No related branches found
No related tags found
No related merge requests found
Pipeline
#
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
installation.md
+52
-33
52 additions, 33 deletions
installation.md
with
52 additions
and
33 deletions
installation.md
+
52
−
33
View file @
d37e3342
...
@@ -17,20 +17,20 @@ sansfont: Sans Serif
...
@@ -17,20 +17,20 @@ sansfont: Sans Serif
-
Installation de la chaîne de compilation:
-
Installation de la chaîne de compilation:
~~~~{#mycode .bash .numberLines}
<pre><code data-trim="hljs sh">
curl https://sh.rustup.rs -sSf | sh
curl https://sh.rustup.rs -sSf | sh
~~~~~~~~~~~~~~~~~~~~~~~~~~
</code></pre>
-
Quelques commandes importantes
-
Quelques commandes importantes
~~~~{#mycode .bash .numberLines}
<pre><code data-trim="hljs sh">
$ rustup install stable # installation de la chaine stable
$ rustup install stable # installation de la chaine stable
$ rustup default stable # chaine par défaut
$ rustup default stable # chaine par défaut
$ rustup self uninstall # désinstallation
$ rustup self uninstall # désinstallation
$ rustup install nightly # installation de la chaine en développement
$ rustup install nightly # installation de la chaine en développement
~~~
</code></pre>
## Contentenu de la chaîne de compilation
of the Toolchain
## Contentenu de la chaîne de compilation
-
`rustc`
{.sh}: compilateur et éditeur de lien
-
`rustc`
{.sh}: compilateur et éditeur de lien
-
`cargo`
{.sh}: outil pour la compilation et gestion de dépendances
-
`cargo`
{.sh}: outil pour la compilation et gestion de dépendances
...
@@ -42,48 +42,67 @@ $ rustup install nightly # installation de la chaine en développement
...
@@ -42,48 +42,67 @@ $ rustup install nightly # installation de la chaine en développement
-
`rustc`
est écrit en Rust (en grande partie).
-
`rustc`
est écrit en Rust (en grande partie).
-
Pour terster l'installation
-
Pour terster l'installation
~~~
{.bash}
<pre><code
data-trim=
"hljs sh"
>
rustc --help
rustc --help
~~~
</code></pre>
## Mon premier `Hello World!`{.rust}
## Mon premier `Hello World!`{.rust}
-
Dans un fichier
`hello_world.rs`
{.bash}.
-
Dans un fichier
`hello_world.rs`
{.bash}.
<pre><code class=lang-rust" data-trim="hljs rust">
<pre><code class=lang-rust" data-trim="hljs rust">
fn main() {
fn main() {
// présent dans tout programme Rust
println!("Hello, World!");
println!("Hello, World!");
// macro d'affichage
}
}
</code></pre>
</code></pre>
-
Pour compiler, éditer les liens et exécuter
-
Pour compiler, éditer les liens et exécuter
~~~
{.bash}
<pre><code data-trim="hljs sh">
$ rustc hello_world.rs
$ rustc hello_world.rs
$ ./hello_world
$ ./hello_world
Hello, World!
Hello, World!
~~~
</code></pre>
## Cargo
## Cargo
<pre><code data-source="chapters/shared/code/installation/6.sh" data-trim="hljs sh"></code></pre>
-
La documentation
[
Cargo Manifest docs
](
http://doc.crates.io/manifest.html
)
.
-
Cargo est l'outil de compilation et gestion de dépendaces de Rust.
Cargo is Rusts build and package management tool.
-
Indépendant de la version de
`rustc`
{.sh}.
-
Permet l'installation d'outil
Cargo is installed along with `rustc`, but is not tightly bound to a `rustc` version.
## Once more with Cargo
<pre><code data-trim="hljs sh">
$ cargo +nightly install clippy # conseil de "beauté du code"
<pre><code data-source="chapters/shared/code/installation/7.sh" data-trim="hljs sh"></code></pre>
$ cargo +nightly install rustfmt # formattage automatique du code
</code></pre>
## A Little Look Around
- What is in Cargo.toml?
- What is in Cargo.lock?
For details, check the [Cargo Manifest docs](http://doc.crates.io/manifest.html).
## Exemple d'utilisation
<pre><code
data-trim=
"hljs sh"
>
$ cargo new hello_world --bin # création projet
$ cd hello_world
$ cargo build # cargo check
Compiling hello_world v0.1.0 (file:///home/malaspor/hello_world)
Finished dev [unoptimized + debuginfo] target(s) in 1.33s
$ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.05s
Running
`target/debug/hello_world`
Hello, world!
$ ./target/debug/hello_world
Hello, world!
$ cargo build --release # compilation avec optimisations
Compiling hello_world v0.1.0 (file:///home/malaspor/Downloads/hello_world)
Finished release [optimized] target(s) in 0.35s
</code></pre>
## Cargo Also Manages Tools
-
Le fichier
`Cargo.toml`
{.sh}:
<pre><code data-source="chapters/shared/code/installation/8.sh" data-trim="hljs sh"></code></pre>
<pre><code
data-trim=
"hljs sh"
>
[package]
name = "hello_world"
version = "0.1.0"
authors = ["Your Name you@example.com"]
[dependencies]
</code></pre>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment