RUST

My friend is working on some stuff in rust and it’s popped up in my job a few times so I wrote an asio sine wave generator in rust to familiarize myself.

FYI the code below is not debugged/cleaned up and definitely has stuff that can be taken out.

Anyone who knows rust probably wont like the way I wrote this, but it does what I set out to do. Which brings me to the stuff I don’t really like about rust on first impressions:

1.) It expects you’re going to develop multi-threaded applications: this is totally reasonable as that is the primary draw of using rust. However if you’re trying to pump out an easy single threaded connect + execute style of device control it can be quite frustrating trying to understand how an API functions.

2.) A lot of error handling: I’m cool with this concept but this is probably going to end up with me putting .except() or ? at the end of majority of my function calls.

3.) Optional static typing: this has always been a pet peeve of mine

The plus sides

1.) Cargo is great

2.) Forcing error management is probably a good practice

3.) Explicitly calling out mutability is a positive in my head

4.) Unsafe blocks are smart (because the primary goal is to make everything thread safe)

If you want this code to work you gotta use cargo to clone down cpal and follow the instructions here: https://github.com/RustAudio/cpal

Leave a Reply