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 |
Linux Device Driver Development Cookbook by Rodolfo Giometti(3932)
Embedded Programming with Modern C++ Cookbook by Igor Viarheichyk(3594)
Implementing Cellular IoT Solutions for Digital Transformation by Dennis McCain(3533)
Embedded Linux Development Using Yocto Project - Third Edition by Otavio Salvador & Daiane Angolini(3361)
TinyML Cookbook by Gian Marco Iodice(3299)
Simplifying 3D Printing with OpenSCAD by Colin Dow(2839)
TinyML Cookbook by Gian Marco Iodice & Ronan Naughton(2601)
Fusion 360 for Makers by Lydia Sloan Cline(2219)
Networking A Beginner's Guide by Bruce Hallberg(2209)
Hands-On Linux for Architects by Denis Salamanca(2051)
But How Do It Know? by J. Clark Scott(2030)
Computers For Seniors For Dummies by Nancy C. Muir(1995)
Raspberry Pi and MQTT Essentials by Dhairya Parikh(1951)
Arduino Project Handbook, Volume 2: 25 Simple Electronics Projects for Beginners by Geddes Mark(1947)
9781803246888-ENHANCING DEEP LEARNING WITH BAYESIAN INFERENCE by Unknown(1899)
Hack and HHVM by Owen Yamauchi(1884)
31 Days Before Your CompTIA A+ Exams (Shanette Luellen's Library) by Benjamin Patrick Conry(1860)
MicroPython Projects by Jacob Beningo(1731)
Hands-On Internet of Things with MQTT by Tim Pulver(1706)
