Learn Rust Programming by Matzinger Claus;
Author:Matzinger, Claus; [Matzinger, Claus]
Language: eng
Format: epub, pdf
Publisher: BPB Publications
Published: 2022-03-15T00:00:00+00:00
Printing custom types
If you create your own type, there is no default formatting implemented, and any attempt to print it will fail with a compiler error. Even if all members of your type are standard types (for example, usize or String), there will not be any default way of printing the type.
That is unless you derive the Debug trait implementation. We will discuss the derive macros in Chapter 11, Generating Code with Macros; for now, just know that a #[derive(Debug)] statement automatically implements the Debug trait by recursively printing each member (this also works for other traits). Here is an example:
#[derive(Debug)]
struct Account {
name: String,
password: [u8; 5] // use 32 for a 256 bit hash (SHA-256)
}
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
| Computer Design | Control Systems |
| DSPs | Embedded Systems |
| Microprocessor Design | PIC Microcontroller |
Embedded Programming with Modern C++ Cookbook by Igor Viarheichyk(4093)
Linux Device Driver Development Cookbook by Rodolfo Giometti(4022)
Implementing Cellular IoT Solutions for Digital Transformation by Dennis McCain(4010)
Embedded Linux Development Using Yocto Project - Third Edition by Otavio Salvador & Daiane Angolini(3870)
TinyML Cookbook by Gian Marco Iodice(3773)
Simplifying 3D Printing with OpenSCAD by Colin Dow(2906)
TinyML Cookbook by Gian Marco Iodice & Ronan Naughton(2659)
Fusion 360 for Makers by Lydia Sloan Cline(2308)
Networking A Beginner's Guide by Bruce Hallberg(2290)
Hands-On Linux for Architects by Denis Salamanca(2132)
Computers For Seniors For Dummies by Nancy C. Muir(2106)
But How Do It Know? by J. Clark Scott(2079)
Raspberry Pi and MQTT Essentials by Dhairya Parikh(2040)
Arduino Project Handbook, Volume 2: 25 Simple Electronics Projects for Beginners by Geddes Mark(1999)
9781803246888-ENHANCING DEEP LEARNING WITH BAYESIAN INFERENCE by Unknown(1971)
Hack and HHVM by Owen Yamauchi(1956)
31 Days Before Your CompTIA A+ Exams (Shanette Luellen's Library) by Benjamin Patrick Conry(1925)
Hands-On Internet of Things with MQTT by Tim Pulver(1828)
MicroPython Projects by Jacob Beningo(1818)