Methods are like functions but defined within the context of structs.
- [Instructor] Methods are similar to functions.…They're declared with the function keyword…and their name, they can have parameters…and returner value and they can contain some code,…that is run when they call from somewhere else.…However, methods are different from functions,…in that they're defined within the context of a struct.…(mumbles) a rotate object, and the first parameter…is always self, which represents the instance…of the structs the method is being called on.…
Let's some starting code for you guys to work on.…So let me just open that.…You should find that in the resources section.…File, open folder.…(mouse clicks)…Go to exercise files, resources,…and open up this directory, methods.…Yeah, we get these popups.…Just don't worry about it and just close it.…Here, let's open the main dot irus,…into associate directory.…As you can see here, the rectangle as a struct…is declared and then an instance of the rectangle…is declared here.…
Let's add the area function that has a rectangle instance…as a parameter, and instant, let's make an area method,…
- 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 Structureswith 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.