- Rust Quick Start Guide
- Daniel Arbuckle
- 191字
- 2021-06-10 19:46:02
Functions
We saw a couple of functions, in passing, in the last chapter when we looked at the automatically generated boilerplate code created by cargo new. What were we actually seeing, though?
A function is a sequence of instructions for the computer to follow. It's sort of like a recipe. We don't have to tell a person how much flour, sugar, and milk to use to bake cookies, if we know that they already have a cookie recipe. We can just say: Bake some cookies, please. It's similar with a function. We don't have to tell the computer exactly how to save some information to a database; if there's a save_to_database function, we can use it to do the job.
In Rust, instructions that can tell the computer to take action can only be written inside of functions. It all starts with a function called main, which can cause other functions to run, which can in turn cause yet more functions to run, and so on. Using our recipe analogy again, it's like a pie recipe saying: Use the recipe on page 57 to make dough for the crust.
- Scratch 3游戲與人工智能編程完全自學(xué)教程
- Python Network Programming Cookbook(Second Edition)
- Windows Forensics Cookbook
- Java程序設(shè)計(jì):原理與范例
- Extending Puppet(Second Edition)
- 響應(yīng)式Web設(shè)計(jì):HTML5和CSS3實(shí)戰(zhàn)(第2版)
- Java EE企業(yè)級(jí)應(yīng)用開發(fā)教程(Spring+Spring MVC+MyBatis)
- Webpack實(shí)戰(zhàn):入門、進(jìn)階與調(diào)優(yōu)(第2版)
- 代碼閱讀
- Qlik Sense? Cookbook
- Struts 2.x權(quán)威指南
- C++17 By Example
- 編程的原則:改善代碼質(zhì)量的101個(gè)方法
- 軟技能2:軟件開發(fā)者職業(yè)生涯指南
- IBM DB2 9.7 Advanced Application Developer Cookbook