- Mastering Rust
- Rahul Sharma Vesa Kaihlavirta
- 99字
- 2021-07-02 13:35:16
Functions and methods on types
Types without behavior can be limiting, and it's often the case that we want to have functions or methods on types so that we can return new instances of them rather than constructing them manually or so that we have the ability to the manipulate fields of a user-defined type. We can do this via impl blocks, which is read as providing implementations for a type. We can provide implementations for all user-defined types or any wrapper type. First, let's take a look at how to write implementations for a struct.
推薦閱讀
- Vue 3移動(dòng)Web開(kāi)發(fā)與性能調(diào)優(yōu)實(shí)戰(zhàn)
- Redis Applied Design Patterns
- Designing Hyper-V Solutions
- Python進(jìn)階編程:編寫(xiě)更高效、優(yōu)雅的Python代碼
- Podman實(shí)戰(zhàn)
- Java 11 Cookbook
- 表哥的Access入門(mén):以Excel視角快速學(xué)習(xí)數(shù)據(jù)庫(kù)開(kāi)發(fā)(第2版)
- Node.js全程實(shí)例
- Raspberry Pi Robotic Blueprints
- Python Machine Learning Blueprints:Intuitive data projects you can relate to
- 零基礎(chǔ)學(xué)HTML+CSS第2版
- Magento 2 Beginners Guide
- 深度學(xué)習(xí)程序設(shè)計(jì)實(shí)戰(zhàn)
- Monitoring Docker
- MySQL數(shù)據(jù)庫(kù)教程(視頻指導(dǎo)版)