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
[-] such0299@sh.itjust.works 1 points 14 hours ago

Hello and Thank You :D Rust really intrigues me so i really want to explore more about Rust

cargo clippy I'll look for Clippy

These comments should be doc-comments (///) so that cargo doc picks them up. I see, i guess i skimmed the Rust Docs :D

but in general you might be interested in crates thiserror and anyhow that simplify error handling. Still, Rust Error Handling and Rust in General is still a big black box for me yet to be unveiled :D, why do i need crates for error handling? But I'll look into it. Still can't quite grasp the concept of Rust

Duration::from_mins(1) would be much more readable. Nice info, never knew this existed before, because i found it in some tutorial that timeout need something in Duration.

You should almost never panic. Your function already returns a Result<>, so you should be using that for error handling. Still figuring how to handle error, but just like what the others say, panic should never occurred, and always return the error

Not Rust specific, but usually I recommend to handle errors first, and return from the function early. This way you reduce cognitive load on the reader, and reduce nesting of if-blocks. That's actually correct, thank you for your input, i always ended with nasty nested if before because of this. Never thought about it before XD

Thank you for your input. I'll refactor my code

[-] hades@programming.dev 1 points 5 minutes ago

Rust Error Handling and Rust in General is still a big black box for me yet to be unveiled :D

Conceptually, error handling in Rust is incredibly simple: if a function can fail, its return type is an enum of either the result of the function (in case of success) or a description of the error that happened. This enum is called Result. See:

why do i need crates for error handling?

You don't. You can 100% handle errors without any additional dependencies, and probably you should be doing that in the beginning. The crates simply add a little bit of syntactic sugar to simplify some boilerplate that you'll have to start writing as soon as your error handling gets sufficiently complex.

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