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
e0866187
There was a problem fetching the pipeline summary.
Commit
e0866187
authored
6 years ago
by
orestis.malaspin
Browse files
Options
Downloads
Patches
Plain Diff
ajout commentaires
parent
7fe3b90f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
commentaires.md
+55
-0
55 additions, 0 deletions
commentaires.md
figs/rust_doc.png
+0
-0
0 additions, 0 deletions
figs/rust_doc.png
with
55 additions
and
0 deletions
commentaires.md
0 → 100644
+
55
−
0
View file @
e0866187
---
title
:
Cours de programmation séquentielle
subtitle
:
Commentaires
author
:
Orestis Malaspinas
sansfont
:
Sans Serif
---
# Commentaires
## Commentaires simples
-
La meilleure façon de commenter son code est de bien nommer variables/fonctions.
-
En rust les commentaires simples viennent après les
`//`
{.rust}.
-
Les commentaires sur plusieurs lignes se commentent avec
`/* ... */`
{.rust}.
<pre><code data-trim="hljs rust" class="lang-rust">
fn main() {
// Tout programme Rust a un point d'entrée qui est
// une fonction fn main().
/*
On peut également documenter sur plusieurs lignes.
Cela se fait comme ceci.
*/
println!("Hello, World!"); // Ceci est un macro en ligne.
}
</code></pre>
## Commentaires de documentation
-
La commande
`cargo doc --open`
{.sh} génère la documentation en HTML.
-
Les lignes de la documentation doivent commencer avec
`///`
{.rust}.
-
Supporte le Markdown pour le formatage du texte :
<pre><code data-trim="hljs rust">
/// Cette fonction ajoute deux, puis multiplie par trois.
///
/// # Exemple
///
///
```
/// let five = 5;
///
/// add_two_mul_three(five);
/// ```
pub fn add_two_mul_three(x: i32) -> i32 {
// ajoutons deux et multiplions par trois
(x + 2)
*
3
}
</code></pre>
-
Le code ci-dessus produit:
!
[](
figs/rust_doc.png
)
{width=100%}
This diff is collapsed.
Click to expand it.
figs/rust_doc.png
0 → 100644
+
0
−
0
View file @
e0866187
61.1 KiB
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