this post was submitted on 19 Mar 2026
17 points (90.5% liked)

Rust

7865 readers
30 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
 

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
[โ€“] BB_C@programming.dev 2 points 1 day ago* (last edited 1 day ago) (1 children)

Only skimmed quickly.

  • Four different hex representations for the same 3 bytes is extremely wasteful. You don't need to store more than a [u8; 3]. You can create a "mapped" struct with those representations if caching them is somehow useful for the use-case. And since we're micro-optimizing memory usage, Box<str> instead of String (for the two fields with actual string data) would be more efficient since those values are not meant to be mutable. You can then serialize to one of the many efficient binary formats around (e.g. borsh). This is not JavaScript, so you can oftentimes not be bound to JSON.
  • Your parsing code looks both unrobust (potentially fragile hard-coded assumptions) and unnecessarily complex. Something much simpler can probably be done with some trivial regex usage.
[โ€“] such0299@sh.itjust.works 1 points 1 day ago

Box instead of String

I need to explore more about this. I really have no idea about this

Your parsing code looks both unrobust (potentially fragile hard-coded assumptions) and unnecessarily complex. Something much simpler can probably be done with some trivial regex usage.

My first approach is using regex, but it seems like overkill? because the data from https://standards-oui.ieee.org/oui/oui.txt is somehow already structured.

But i'll try the regex approach later.

Thank you :D