Functions are an invariable part of any programming language and like in other programming languages, Rust uses functions to increase code reusability and modularity.
- [Narrator] A function is a block…of organized, reusable code that is used…to perform a single related action.…Functions provide better modularity for your application…and a high degree of code reusing.…Let me just open up "hello_word.rs,"…the first Rust file we've written.…We've already seen one of the most important functions…in the language, the main function,…which is the entry point of many programs.…We have also seen the fn keyword,…which allows you to declare new functions.…
Rust code uses snake case as the conventional style…for function and variable names.…In snake case, all letters are lowercase…and underscores separate words.…Function definitions in Rust start with "fn"…and have a set of parentheses after the function name.…The curly brackets tell the compiler…where the function body begins and where it ends.…Let's open up our command prompt…and start a new binary project named "functions."…You know how to do it.…
"Cargo new functions"…followed by "bin."…This creates the functions project.…Let's head to our code editor and open the functions project…
- Installing Rust
- Data types
- Adjusting memory allocation
- Setting up race conditions
- Working with functions
- Exploring references and borrowing
- Using structs
- Method syntax
- Demonstrating recoverable errors with Result
- Working with enums
- Getting user input
Skill Level Beginner
Programming Foundations: Data Structures (2014)with Simon Allardice2h 29m Intermediate
1. Hello, Rust!
2. Basic Programming Concepts
3. Ownership in Rust
4. Data Handling and Pattern Matching in Rust
5. Error Handling
6. Sample Rust Project: The Guessing Game
Next steps1m 14s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.