issue161:c_c
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
issue161:c_c [2020/09/28 08:03] – d52fr | issue161:c_c [2020/10/01 16:21] (Version actuelle) – andre_domenech | ||
---|---|---|---|
Ligne 15: | Ligne 15: | ||
fn average(x: i32, y: i32, z: i32 ) -> i32 | fn average(x: i32, y: i32, z: i32 ) -> i32 | ||
- | **Note that the arrow is not ‘=>’ like we used before. But that is also not where the odd things end; if you want to return a value, you do not end the statement with a semicolon.** | + | Note that the arrow is not ‘=>’ like we used before. But that is also not where the odd things end; if you want to return a value, you do not end the statement with a semicolon.** |
- | Quand nous avons besoin d' | + | Quand nous avons besoin d' |
fn average(x: i32, y: i32, z: i32 ) -> i32 | fn average(x: i32, y: i32, z: i32 ) -> i32 | ||
Ligne 23: | Ligne 23: | ||
Notez que la flèche n'est pas le « => » que nous avons utilisé précédemment. Mais ce n'est pas pour ça qu'il n'y a plus de choses bizarres ; si vous voulez retourner une valeur, vous ne devez pas terminer la déclaration avec un point-virgule. | Notez que la flèche n'est pas le « => » que nous avons utilisé précédemment. Mais ce n'est pas pour ça qu'il n'y a plus de choses bizarres ; si vous voulez retourner une valeur, vous ne devez pas terminer la déclaration avec un point-virgule. | ||
- | Those trip me up, though if you think about it, makes perfect sense. I know we are hopping back to 3.3 in the book, but I thought it was important to point it out, as it is mentioned, but often overlooked. Now we can move on to part 7. | + | **Those trip me up, though if you think about it, makes perfect sense. I know we are hopping back to 3.3 in the book, but I thought it was important to point it out, as it is mentioned, but often overlooked. Now we can move on to part 7. |
In the beginning, when crates were mentioned, I thought of them as packages. But in Rust, we need to be clear: A package is one or more crates that provide a set of functionality. A package contains a ‘cargo.toml’ file that describes how to build those crates.** | In the beginning, when crates were mentioned, I thought of them as packages. But in Rust, we need to be clear: A package is one or more crates that provide a set of functionality. A package contains a ‘cargo.toml’ file that describes how to build those crates.** | ||
+ | |||
+ | Ces points m'ont posé un problème ; mais, si vous y réfléchissez bien, ça a tout son sens. Je sais que nous revenons à la section 3.3 du livre, mais je pense qu'il est important de le souligner, car il est indiqué, mais souvent négligé. Maintenant, nous pouvons passer à la partie 7. | ||
+ | |||
+ | Au début, quand les « crates » ont été citées, je les voyais comme des paquets. Mais, dans Rust, nous devons être clair : un « Package » (paquet) est un ou plusieurs « crates » (cagette) qui fournissent un ensemble de fonctionnalités. Un paquet contient un fichier « cargo.toml » qui décrit comment construire les crates. | ||
**You will notice that the book refers us back to chapter 2, where we used the ‘rand’ crate, for random numbers. TL;DR we had to add a [dependencies] section and add rand. We also needed to build our file to reflect the changes with: ‘cargo build’. We used the random generator with ‘use rand:: | **You will notice that the book refers us back to chapter 2, where we used the ‘rand’ crate, for random numbers. TL;DR we had to add a [dependencies] section and add rand. We also needed to build our file to reflect the changes with: ‘cargo build’. We used the random generator with ‘use rand:: | ||
+ | |||
+ | Vous remarquerez que le livre nous fait nous référer au chapitre 2, où nous avons utilisé le crate « rand », pour les nombres aléatoires. En bref : nous avons dû ajouter une section [dependencies] (dépendances) et ajouter rand. Pour refléter les modifications, | ||
**Speaking of errors, do section 7.3, to catch that error. Now, when you head to section 7.4, you may be disgusted that they mention the ‘use’ keyword only now, after you have typed so many paths and double-colons you get nightmares about it. That is the reason I mention it now so you do not skip anything in section 7.4. On that note, the book does refer you to chapter 14, cargo workspaces. I suggest that if you are a noob, do not jump here, you need to have worked your way through at least chapter 12, before attempting chapter 14.** | **Speaking of errors, do section 7.3, to catch that error. Now, when you head to section 7.4, you may be disgusted that they mention the ‘use’ keyword only now, after you have typed so many paths and double-colons you get nightmares about it. That is the reason I mention it now so you do not skip anything in section 7.4. On that note, the book does refer you to chapter 14, cargo workspaces. I suggest that if you are a noob, do not jump here, you need to have worked your way through at least chapter 12, before attempting chapter 14.** | ||
+ | |||
+ | À propos d' | ||
**Let us quickly talk about ownership and borrowing. This is one of the legs that Rust stands on. Grasping this will help you a lot. Lots of programming of non-trivial programs will have you getting data, manipulating that data in some way, then outputting the result. This book in your web browser is a nice example. When you click on the link to chapter 14, it figures out where that page is stored, grabs the data and displays it in your browser. The speed of data is usually connected to where it is stored. If your data is on the internet, like a web page, it is slow as it needs to be lifted from long-term memory (disk) to short-term memory (ram), and then sent over the network. If your data is local, it just needs to do the first two steps and if it is in memory, that is only one step. Reading from disk is slower than reading from memory. Speed is not the only consideration here, space is another. Google has millions of gigabytes to store data on. Your hard drive may have only thousands of gigabytes and your memory in the tens column. So, as the speed increases, it becomes necessary to manage the space as you do not have an infinite amount. We can look into the concepts of ownership and borrowing if there is interest, but this is a good topic for you to read up on in your favourite browser as it is covered in section 4, but I suggest adding another source to get a different perspective. ** | **Let us quickly talk about ownership and borrowing. This is one of the legs that Rust stands on. Grasping this will help you a lot. Lots of programming of non-trivial programs will have you getting data, manipulating that data in some way, then outputting the result. This book in your web browser is a nice example. When you click on the link to chapter 14, it figures out where that page is stored, grabs the data and displays it in your browser. The speed of data is usually connected to where it is stored. If your data is on the internet, like a web page, it is slow as it needs to be lifted from long-term memory (disk) to short-term memory (ram), and then sent over the network. If your data is local, it just needs to do the first two steps and if it is in memory, that is only one step. Reading from disk is slower than reading from memory. Speed is not the only consideration here, space is another. Google has millions of gigabytes to store data on. Your hard drive may have only thousands of gigabytes and your memory in the tens column. So, as the speed increases, it becomes necessary to manage the space as you do not have an infinite amount. We can look into the concepts of ownership and borrowing if there is interest, but this is a good topic for you to read up on in your favourite browser as it is covered in section 4, but I suggest adding another source to get a different perspective. ** | ||
+ | |||
+ | Parlons rapidement de propriété et d' | ||
**That’s it for now. Next issue we will look at other things. | **That’s it for now. Next issue we will look at other things. | ||
Ligne 36: | Ligne 47: | ||
As always, if you need to reach us: misc@fullcirclemagazine.org** | As always, if you need to reach us: misc@fullcirclemagazine.org** | ||
- | C'est tout pour aujoued'hui. La prochaine fois, nous regarderons d' | + | C'est tout pour aujourd'hui. La prochaine fois, nous regarderons d' |
Comme d' | Comme d' | ||
issue161/c_c.1601272998.txt.gz · Dernière modification : 2020/09/28 08:03 de d52fr