14
submitted 1 day ago* (last edited 14 hours ago) by such0299@sh.itjust.works to c/rust@programming.dev

Hello

I've been interested with Rust for the last year, but cannot find time to learn Rust.

Coming from Python, i have found my self quite difficult to learn Rust and grasp its concepts.

So, for the last couple of weeks, i have been able to spare some times to learn Rust, and created a mini project to parse Vendor OUI with Rust.

If you would be so kind to spare some of your time to review my code and give me some constructive feedback on how to tackle this, and some guidance for me about what i can improve because its not the rust way of doing things, i would be very happy. I want to improve my skills on Rust so i have another tools in my toolbox

This is not a promotion, because i believe there's another tools just like mine out there nor i want you to use my project, because this project is only for me to test my skill for using Rust.

Thank you in advanced :D

=== Additional text after posting ===

Thank you for those who reply, i really learned something new. I'll try to improve my code :D

Shout Out to Nous, Hades, Kwdg, BB_C

<3

you are viewing a single comment's thread
view the rest of the comments
[-] nous@programming.dev 3 points 21 hours ago

You panic a lot on errors in functions where you return a result. Almost all of these are due to input problems not programming logic errors. These really should be return from the functions as errors so higher up functions can handle them how they might need to rather than just imminently crashing the program. Really panics should only be used when the situation should never occur and if it does that indicates a bug in the program - or you are being lazy with small/test code/one off scripts (but in this case why return any errors at all, you might as well just .unwrap() on everything instead of ?.

[-] such0299@sh.itjust.works 1 points 14 hours ago

To Panic or not to Panic Thank you for your pointer. I just remember this from the docs. So basically, the general rule is only to use panic when something bad really happened, and my program cannot continue right? otherwise always return the error?

Really panics should only be used when the situation should never occur and if it does that indicates a bug in the program

I'll rethink the use of panic in my code

would this section suffice? https://doc.rust-lang.org/book/ch09-00-error-handling.html

this post was submitted on 19 Mar 2026
14 points (93.8% liked)

Rust

7865 readers
41 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 2 years ago
MODERATORS