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
bcd6414c
There was a problem fetching the pipeline summary.
Commit
bcd6414c
authored
6 years ago
by
orestis.malaspin
Browse files
Options
Downloads
Patches
Plain Diff
ajouts divers fonctions
parent
b6dbb4a7
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
control.md
+2
-2
2 additions, 2 deletions
control.md
fonctions.md
+38
-10
38 additions, 10 deletions
fonctions.md
with
40 additions
and
12 deletions
control.md
+
2
−
2
View file @
bcd6414c
...
@@ -115,7 +115,7 @@ fn main() {
...
@@ -115,7 +115,7 @@ fn main() {
-
On sort d'une boucle avec
`break`
{.rust}
-
On sort d'une boucle avec
`break`
{.rust}
<pre><code data-trim="hljs rust" class="lang-rust">
<pre><code
data-trim=
"hljs rust"
class=
"lang-rust"
>
fn main() {
fn main() {
let mut i = 0;
let mut i = 0;
loop {
loop {
...
@@ -129,7 +129,7 @@ fn main() {
...
@@ -129,7 +129,7 @@ fn main() {
}
}
}
}
}
}
</code></pre>
</code></pre>
## La boucle `while`{.rust}
## La boucle `while`{.rust}
...
...
This diff is collapsed.
Click to expand it.
fonctions.md
+
38
−
10
View file @
bcd6414c
...
@@ -22,7 +22,7 @@ sansfont: Sans Serif
...
@@ -22,7 +22,7 @@ sansfont: Sans Serif
<!-- slide-numbers
:
true
-->
<!-- slide-numbers
:
true
-->
---
---
#
Les i
nstructions et
les
expressions
#
I
nstructions et expressions
## Les instructions (statements)
## Les instructions (statements)
...
@@ -32,7 +32,7 @@ sansfont: Sans Serif
...
@@ -32,7 +32,7 @@ sansfont: Sans Serif
```{.lang-rust}
```{.lang-rust}
let x = 1; // une instruction
let x = 1; // une instruction
```
```
-
On ne peut pas assigner une instruction
-
On ne peut pas assigner une instruction
`let`
{.rust}
<pre><code
data-trim=
"hljs rust"
class=
"lang-rust"
>
<pre><code
data-trim=
"hljs rust"
class=
"lang-rust"
>
fn main() {
fn main() {
...
@@ -50,14 +50,42 @@ sansfont: Sans Serif
...
@@ -50,14 +50,42 @@ sansfont: Sans Serif
```
```
-
La plupart du code rust est une expression.
-
La plupart du code rust est une expression.
-
N'importe quel bloc peut effectuer des opérations et retourner une valeur.
-
N'importe quel
**
bloc
**
peut effectuer des opérations et retourner une valeur.
<pre><code
data-trim=
"hljs rust"
class=
"lang-rust"
>
<pre><code
data-trim=
"hljs rust"
class=
"lang-rust"
>
fn main() {
fn main() {
let y = {
let y = {
let x = 5 + 3;
let x = 5 + 3;
x - 9
x - 9
};
};
println!("5 + 3 - 9 = {}", y);
println!("5 + 3 - 9 = {}", y);
}
}
</code></pre>
</code></pre>
-
**Important:**
Une expression sans
`;`
dans un bloc retourne la valeur evaluée de l'expression.
# Fonctions
## Généralités
-
Les fonctions s'écrivent en
*snake_case*
(le compilateur vous avertiras...).
-
La définition d'une fonction commence par un
`fn`
{.rust}.
-
La définition des fonctions peut se faire avant ou après l'endroit où elle est appelée.
<pre><code data-trim="hljs rust" class="lang-rust">
fn main() {
println!("La fonction main est une fonction.");
fonction_fonction();
}
fn fonction_fonction() {
println!("La fonction fonction_fonction est une fonction.");
}
</code></pre>
## Paramètres de fonctions
-
Une fonction peut prendre des arguments séparés par des
`,`
{.rust}.
-
Le type des arguments doit toujours être explicitement déclaré.
-
\ No newline at end of file
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