- 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.
推薦閱讀
- 手機(jī)安全和可信應(yīng)用開發(fā)指南:TrustZone與OP-TEE技術(shù)詳解
- 自己動(dòng)手實(shí)現(xiàn)Lua:虛擬機(jī)、編譯器和標(biāo)準(zhǔn)庫
- Learning C++ Functional Programming
- Hands-On JavaScript High Performance
- Java深入解析:透析Java本質(zhì)的36個(gè)話題
- iOS應(yīng)用逆向工程(第2版)
- Kubernetes源碼剖析
- INSTANT Silverlight 5 Animation
- QGIS 2 Cookbook
- Getting Started with Polymer
- Nagios Core Administration Cookbook(Second Edition)
- SignalR:Real-time Application Development(Second Edition)
- 面向?qū)ο蟪绦蛟O(shè)計(jì)及C++(第3版)
- Unreal Engine Game Development Cookbook
- 嵌入式Linux與物聯(lián)網(wǎng)軟件開發(fā):C語言內(nèi)核深度解析