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

Rain Paharia

๐Ÿ‘ค Speaker
467 total appearances

Appearances Over Time

Podcast Appearances

Oxide and Friends
Crates We Love

So one of the things that I've noticed when defining, say, a configuration file is that people will often misspell things, right? Surdy has this really cool deny unknown fields feature. Yeah, I love this. Right? So, and deny unknown fields is great, but sometimes you don't want an error, you instead want a warning. And Surdy ignored actually kind of lets you get that warning.

Oxide and Friends
Crates We Love

So it's kind of somewhere in the middle between like the silently accepting the, you know, maybe the typo. or failing, and I really like Serdy Ignored for that because often you want to support some kind of forward compatibility, and if you have that forward compatibility, then you don't just want to choke if you see a new option or whatever, right?

Oxide and Friends
Crates We Love

So it's kind of somewhere in the middle between like the silently accepting the, you know, maybe the typo. or failing, and I really like Serdy Ignored for that because often you want to support some kind of forward compatibility, and if you have that forward compatibility, then you don't just want to choke if you see a new option or whatever, right?

Oxide and Friends
Crates We Love

And so Serdy Ignored does a really, really good job of reporting that. And then kind of paired with that, but kind of solving a slightly different problem, is certipath2error. And what certipath2error does is it will try and report the nearest part of kind of what failed. So it'll kind of maintain some state and like, you know, which keys have you traversed into and so on.

Oxide and Friends
Crates We Love

And so Serdy Ignored does a really, really good job of reporting that. And then kind of paired with that, but kind of solving a slightly different problem, is certipath2error. And what certipath2error does is it will try and report the nearest part of kind of what failed. So it'll kind of maintain some state and like, you know, which keys have you traversed into and so on.

Oxide and Friends
Crates We Love

And it does a pretty good job of that. So, you know, there's one specific asterisk which we don't really want to kind of get into right now because it detracts. But overall, like this pair of crates has just kind of been, I feel like this has like really elevated the, you know, like kind of error handling experience around configuration files for me.

Oxide and Friends
Crates We Love

And it does a pretty good job of that. So, you know, there's one specific asterisk which we don't really want to kind of get into right now because it detracts. But overall, like this pair of crates has just kind of been, I feel like this has like really elevated the, you know, like kind of error handling experience around configuration files for me.

Oxide and Friends
Crates We Love

Oh, boy. Um, uh, that was actually, uh, as far as, uh, I mean, I had a couple of other detail nuggets, but they'll come up there. Um, another crate that I wanted to call out, uh, and kind of, you know, as a cool proc macro crate is, uh, derive where, um, so, um, so one of the things that, you know, kind of people run into sometimes is that, uh, you want to do say like a derived debug, right.

Oxide and Friends
Crates We Love

Oh, boy. Um, uh, that was actually, uh, as far as, uh, I mean, I had a couple of other detail nuggets, but they'll come up there. Um, another crate that I wanted to call out, uh, and kind of, you know, as a cool proc macro crate is, uh, derive where, um, so, um, so one of the things that, you know, kind of people run into sometimes is that, uh, you want to do say like a derived debug, right.

Oxide and Friends
Crates We Love

Um, or like a derived clone or something. And like, uh, if you have a. create which has a generic, like t colon clone, then the implementation that Rust generates is you only derive clone if t also implements clone. You only get to implement clone that way. That is like mostly what you want, but sometimes not. And so, you know, one option is you, if you don't want that clone bound, right?

Oxide and Friends
Crates We Love

Um, or like a derived clone or something. And like, uh, if you have a. create which has a generic, like t colon clone, then the implementation that Rust generates is you only derive clone if t also implements clone. You only get to implement clone that way. That is like mostly what you want, but sometimes not. And so, you know, one option is you, if you don't want that clone bound, right?

Oxide and Friends
Crates We Love

Like sometimes you're not actually storing a T in there. You are storing, say, some kind of derivative type of T. then you do that. But the one I really like that kind of automates this is derive where. So what derive where lets you do is it lets you say derive clone where sum bound. So you can say derive t clone, sorry, derive

Oxide and Friends
Crates We Love

Like sometimes you're not actually storing a T in there. You are storing, say, some kind of derivative type of T. then you do that. But the one I really like that kind of automates this is derive where. So what derive where lets you do is it lets you say derive clone where sum bound. So you can say derive t clone, sorry, derive

Oxide and Friends
Crates We Love

my type clone where T is, you know, like some implementation, some implementation of some trait that you've defined, but you can also save like, you know, you don't have any restrictions on T. So you can just do derive where clone. I remember like showing something else at a demo day and then everyone else was like, what's this derive where thing?

Oxide and Friends
Crates We Love

my type clone where T is, you know, like some implementation, some implementation of some trait that you've defined, but you can also save like, you know, you don't have any restrictions on T. So you can just do derive where clone. I remember like showing something else at a demo day and then everyone else was like, what's this derive where thing?

Oxide and Friends
Crates We Love

And then that ended up joining into the Driveware demo. It was very funny. But it's a create that I really like, and I end up reaching for it a few times a year. How does this work? As far as I can tell, it just generates a proc macro that iterates over the fields. But it just puts bounds on them. So it's just a proc macro in that sense.

Oxide and Friends
Crates We Love

And then that ended up joining into the Driveware demo. It was very funny. But it's a create that I really like, and I end up reaching for it a few times a year. How does this work? As far as I can tell, it just generates a proc macro that iterates over the fields. But it just puts bounds on them. So it's just a proc macro in that sense.

Oxide and Friends
Crates We Love

Yeah. Definitely one of my favorite little proc macros that help out.

Oxide and Friends
Crates We Love

Yeah. Definitely one of my favorite little proc macros that help out.

Oxide and Friends
Crates We Love

I think what I ended up having was I was storing a phantom data of D or something like that. So I was storing like... So I had this thing which only stored the T as a marker, so it didn't actually store any concrete values of T. And implementing something like clone for that should not require that T implement clone, right? Just logically, that is not a requirement.