Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rust-101
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
Package Registry
Model registry
Operate
Environments
Terraform modules
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-101
Commits
7678a15c
Commit
7678a15c
authored
7 months ago
by
orestis.malaspin
Browse files
Options
Downloads
Plain Diff
Merge branch 'fixes' into 'main'
different fixes See merge request
!77
parents
d4108ebe
73976add
No related branches found
Branches containing commit
No related tags found
1 merge request
!77
different fixes
Pipeline
#33813
passed
7 months ago
Stage: test
Stage: build
Stage: deploy
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
slides/src/generics.md
+1
-1
1 addition, 1 deletion
slides/src/generics.md
slides/src/methods.md
+2
-1
2 additions, 1 deletion
slides/src/methods.md
slides/src/ownership.md
+1
-1
1 addition, 1 deletion
slides/src/ownership.md
with
4 additions
and
3 deletions
slides/src/generics.md
+
1
−
1
View file @
7678a15c
...
...
@@ -36,7 +36,7 @@ fn max<T>(a: T, b: T) -> T {
## Vrai exemple avec générique
```
rust
// On doit dire au compilateur que T implémente "<
/
>"
// On doit dire au compilateur que T implémente "<
,
>"
fn
max
<
T
:
PartialOrd
>
(
a
:
T
,
b
:
T
)
->
T
{
if
a
>
b
{
a
}
else
{
b
}
}
...
...
This diff is collapsed.
Click to expand it.
slides/src/methods.md
+
2
−
1
View file @
7678a15c
...
...
@@ -61,6 +61,7 @@ impl Rectangle { // les méthodes de Rectangle se trouvent dans un bloc impl
}
fn main() {
let rect = Rectangle { width: 10, height: 5 };
// Problème ?
println!("La surface de ce rectangle
est donnée par {} et son périmètre par {}.",
rect.area(), rect.perimeter());
...
...
@@ -108,7 +109,7 @@ impl Rectangle { // les méthodes de Rectangle se trouvent dans un bloc impl
fn
main
()
{
let
mut
rect
=
Rectangle
{
width
:
10
,
height
:
5
};
// rect doit être mutable
rect
.set_width
(
1_000_000
);
// pour que cette ligne compile
println!
(
"On a modifié width. L'instance de rectanle est {:?}."
,
rect
);
println!
(
"On a modifié width. L'instance de rectan
g
le est {:?}."
,
rect
);
}
```
...
...
This diff is collapsed.
Click to expand it.
slides/src/ownership.md
+
1
−
1
View file @
7678a15c
...
...
@@ -326,7 +326,7 @@ fn main() {
fn
main
()
{
let
mut
y
=
Vec
::
new
();
y
.push
(
1
);
y
.push
(
2
);
y
.push
(
3
);
y
.push
(
4
);
{
{
// optionnel, le compilo est smart
let
mut
y1
=
&
mut
y
;
y1
.push
(
7
);
}
...
...
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