rustbites rustbites bite-sized rust tips
Archives About
#022 Nov 11, 2022
option iterator

22. Enum's Debug

Use Debug trait to print enum values if needed.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
#[derive(Default,Debug)]
enum Car{
    #[default]
    Porsche,
    Ferrari,
    Skoda
}

let car = Car::default();
println!("{:?}", car);

This post is licensed under CC BY 4.0 by the author.

Share:
← Previous 21. Zip longest Next → 23. Enum's default value

Trending Tags

Rust Iterator Option Iter Iterators Result Collections Enum Macro Match Std Vec Array-Windows Arrays Async Attributes Break Closure Closures Combinators Compiler Concurrency Cow Debugging Default Drain Entry Enumerate Error-Handling Filter Flatten Fn Fnmut Fnonce Fold From_fn Functional Hashmap If-Let Initialization Lazy Lazylock Loop Map Matching Mem Ownership Pattern-Matching Performance Pettern Position Raw String Scan Scoped-Threads Slices Smart-Pointers Static Stdlib String Strings Threads Tokio Trait-Objects Traits Upcasting

Recently updated

#043 43. Vec::extract_if — Remove Elements and Keep Them #042 42. array::from_fn — Build Arrays from a Function #041 41. Async Closures — Pass Async Code Like Any Other Closure #040 40. Scoped Threads — Borrow Across Threads Without Arc #039 39. Trait Upcasting — Cast dyn Trait to dyn Supertrait

About

A collection of bite-sized Rust tips and tricks. Small, focused lessons to help you write better Rust.

info@rustbites.com
rustbites rustbites · 2022—2026
X RSS

This site uses cookies for analytics and ads. Learn more