Menu
Sign In Search Podcasts Charts People & Topics Add Podcast API Blog Pricing

Sebastian Scholz

๐Ÿ‘ค Speaker
485 total appearances

Appearances Over Time

Podcast Appearances

Rust in Production
Gama Space with Sebastian Scholz

So instead of writing a huge state machine, basically, like that, you can write your code more freely, just at any given structure that you want, just passing around these types of keys.

Rust in Production
Gama Space with Sebastian Scholz

Well, it's definitely used in the embedded world a lot, maybe not in the same kind of a way, but we've got the idea from crates like Embassy and actually various hardware abstraction layer crates that if you, in the beginning, they give you one struct that contains all of the peripherals, like a

Rust in Production
Gama Space with Sebastian Scholz

But it's just serialized types for these peripherals.

Rust in Production
Gama Space with Sebastian Scholz

And the idea behind that is that you can then, when you want to use one of these peripherals, you have to consume that type.

Rust in Production
Gama Space with Sebastian Scholz

And that prevents you from using the same peripheral twice.

Rust in Production
Gama Space with Sebastian Scholz

For example, pins.

Rust in Production
Gama Space with Sebastian Scholz

If you think about microcontroller, it has pins that you can toggle on or off.

Rust in Production
Gama Space with Sebastian Scholz

And if you decided at one point, yes, okay, I'm going to use this pin to, I don't know, to talk to a motor, for example.

Rust in Production
Gama Space with Sebastian Scholz

And then later you think, okay, wait, I have another use for a pin.

Rust in Production
Gama Space with Sebastian Scholz

Maybe, I don't know, I want to toggle an LED or something.

Rust in Production
Gama Space with Sebastian Scholz

let me see, maybe pin one is still available.

Rust in Production
Gama Space with Sebastian Scholz

I'm going to try to use it.

Rust in Production
Gama Space with Sebastian Scholz

Ah, no, I've already used this before.

Rust in Production
Gama Space with Sebastian Scholz

And Rust tells you this because you moved the type, you moved the variable into the function that used it.

Rust in Production
Gama Space with Sebastian Scholz

And so you can't use it later.

Rust in Production
Gama Space with Sebastian Scholz

And so that's kind of the same idea.

Rust in Production
Gama Space with Sebastian Scholz

You have a token for each peripheral, for each pin that you can only use once.

Rust in Production
Gama Space with Sebastian Scholz

And this is one of the things I really love about Rust is

Rust in Production
Gama Space with Sebastian Scholz

It's the ability to detect these kind of configuration errors at compile time.

Rust in Production
Gama Space with Sebastian Scholz

I mean, the compiler literally prevents you from writing code that is wrongly configured that would be valid code just from a processor perspective.