nerdblood

joined 1 year ago
[–] [email protected] 1 points 1 year ago (2 children)

One for now, theoretically many later.

Nice I've never used Rc. Maybe now's my chance to look into it.

[–] [email protected] 2 points 1 year ago

🀯 that's how it should be. I'm sick of shenanigans.

[–] [email protected] 1 points 1 year ago (2 children)

I haven't tried it with Deno. Is it less of a pain to get started with project s that use TS than node?

[–] [email protected] 4 points 1 year ago

Also, move out special types to types.rs, error types to errors.rs to keep the area with the actual algorithms more clear.

Ok this is totally something my code base needs. Very actionable feedback.

And yeah that's one of the things I love about rust; it will tell me everywhere things are out of wack. It's such a different experience from back when I had large JavaScript code bases. Make changes and pray lol.

[–] [email protected] 3 points 1 year ago

This is really good to hear, I don't think I'm as far off base as I thought; maybe I've been over thinking it a bit. And thanks for that refactoring resource. I'm very big into making my TS code clean and maintainable. I'm just thrown off a bit with the new paradigm.

[–] [email protected] 1 points 1 year ago

Oh wow, default is so nice. I wasn't exactly looking for this when I asked the question, but I'm glad you tipped me off to it.

[–] [email protected] 1 points 1 year ago

Default could be useful here, thanks!

[–] [email protected] 3 points 1 year ago

Thanks, yeah it felt like too many tests to keep in file. I can live with that directory approach. TY!

[–] [email protected] 1 points 1 year ago

Error handling was kind of a pain to wrap my head around within the Rust Ecosystem, between the different crates, custom enums and learning about Box. I do enjoy errors now that I understand how the community is using them a little better, and the idea of there being one control flow with errors being a possible 'result'.

Author seems to have some good experience composing errors in Rust applications... good read!

[–] [email protected] 3 points 1 year ago

This is cool. I'm a front-end focused dev by trade and have been 11 years now. I've been picking up Rust as a side hobbie for 6 months or so and have not even peaked at these front-end frameworks. I know Lemmy is all about Rust, but I still think it's pretty cheeky they're using Rust for the front-end.

About Leptos specifically... If there's no shadow dom / rerenders and not trying to be react, I already like it better than it's competitor.

[–] [email protected] 2 points 1 year ago

I'd provide more code but it's a mess and full of old commented-out code. Your examples are perfect! combining the DB fields into it's own struct is something I hadn't thought of... and I totally get why having a bunch of options sitting in the Army struct would be problematic. I'm really excited about rust for moving these sorts of errors to compile time.

The INTO example seems great too. I'm ok with the performance hit of cloning for now... lifetimes and pointers feel like a tier above where am at with my rust skills, and I'll circle back to get a better handle on them later.

One question about the INTO example... I always hear it's better to just implement FROM and get INTO for free. Does that not make sense for my use case? If I did it, would it look something like:

impl From<ArmyWithDbProps> for Army { fn from(self) -> ArmyWithDbProps { self.armyWithDbProps } }

[–] [email protected] 2 points 1 year ago* (last edited 1 year ago) (2 children)

If you absolutely can’t make it work, a single Option at least would be more correct as all the fields on the inner struct would be optional together.

Wait really? If I wrap a struct in Option it makes all the fields optional?

Good to know that you think the Into approach seems better. Part of the purpose of this thread is to just gauge what's the better way to do this in Rust. Do you know what "separating the types with Into" would look like?

view more: β€Ή prev next β€Ί