mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2026-12-01 03:30:25 +08:00
* refactor: clean to roadmap content * refactor: move shared helpers into scripts/lib
1.0 KiB
1.0 KiB
Impl Blocks
Impl blocks use the impl keyword, and are used to implement behavior in the form of methods for a struct, enum, or trait. If you want your data type or trait to have methods, you need a corresponding impl block containing functions for the type or trait.
Note that self and Self have different meanings in the context of an impl block's functions. self represents the specific value in your program that's calling the method and passing itself as an argument, while Self is syntax sugar for the impl block's data type, which is commonly used in constructor methods that return a new instance of the type.
Visit the following resources to learn more: