- 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.
推薦閱讀
- 深入理解Bootstrap
- AngularJS深度剖析與最佳實(shí)踐
- 云原生Spring實(shí)戰(zhàn)
- Internet of Things with the Arduino Yún
- Learning Neo4j 3.x(Second Edition)
- YARN Essentials
- Mastering macOS Programming
- Troubleshooting PostgreSQL
- 深入分布式緩存:從原理到實(shí)踐
- Microsoft Azure Storage Essentials
- 零基礎(chǔ)Java學(xué)習(xí)筆記
- Serverless Web Applications with React and Firebase
- Java Web從入門到精通(第2版)
- 零基礎(chǔ)學(xué)HTML+CSS第2版
- 你真的會(huì)寫代碼嗎