abrahambelch

joined 8 months ago
[–] abrahambelch@programming.dev 19 points 1 day ago (1 children)

It Feels Almost Like Android... But It Isn't

So what is it?

Lmao, the part about the control center feeling like from a bootleg phone made my day. I felt like something was off the whole time but couldn't tell what was bothering me

[–] abrahambelch@programming.dev 2 points 2 days ago (1 children)

Yeah and I can't get my head around why it won't be available here in the EU. This is so fucking stupid! Like how is the DMA or any other legislation supposed to prevent them from implementing iPhone mirroring? They literally offer every other continuity-related feature over here. This is just Apple being upset they're actually being regulated in the EU.

That's what I wanted to say as well! Most AI stuff in software development is bullshit, but full line completion is actually so useful!

[–] abrahambelch@programming.dev 14 points 1 week ago* (last edited 1 week ago)

I'd return a non-zero value so they know it's their fault ^^

[–] abrahambelch@programming.dev 6 points 1 week ago* (last edited 1 week ago) (2 children)

In my personal opinion: Yes. Wine is great and all, but in the end it's an emulation layer that - in the worst case - requires a lot of tweaking. I personally wouldn't want to spend that time so a VM sounds like a good option. But again, depending on the context (e.g. limited hardware resources or the amount of time available) you might be totally fine with Wine.

[–] abrahambelch@programming.dev 3 points 3 weeks ago (3 children)

Do you still remember the name of the Johto rom hack made in the Gen 3 engine? I'd love to give it a try!

[–] abrahambelch@programming.dev 11 points 3 weeks ago* (last edited 3 weeks ago) (1 children)

Shit gets weird when the guy in 418 opens and claims to be a tea pot...

[–] abrahambelch@programming.dev 1 points 3 weeks ago* (last edited 3 weeks ago)

You're right. Also the other way around the new Kotlin frameworks needed can't easily be used in a Java codebase. I mean on bytecode level they're compatible but it's basically impossible in practice

[–] abrahambelch@programming.dev 3 points 1 month ago (1 children)

That makes sense, thanks again! I think dynamic dispatch is not as much of a performance issue in my case, yet you're totally right not to waste resources that aren't actually needed. Keeping things on the stack if possible is also a good thing.

I'll definitely need to read more about Rusts type system but your explanation was already very helpful! I think this might be why my initial approach felt unnatural - it works but is quite cumbersome and with generics there seems to be a more elegant approach.

[–] abrahambelch@programming.dev 5 points 1 month ago

Thanks for your input! I'll have a look at both build flags and macros for sure! For my specific problem enums will do just fine I guess, but having an overview about the possibilities helps a lot!

[–] abrahambelch@programming.dev 1 points 1 month ago

Thanks for your reply!

31
Strategy Pattern in Rust (programming.dev)
submitted 1 month ago* (last edited 1 month ago) by abrahambelch@programming.dev to c/rust@programming.dev
 

Hey there, I'm currently learning Rust (coming from object-oriented and also to some degree functional languages like Kotlin) and have some trouble how to design my software in a Rust-like way. I'm hoping someone could help me out with an explanation here :-)

I just started reading the book in order to get an overview of the language as well.

In OOP languages, I frequently use design patterns such as the Strategy pattern to model interchangeable pieces of logic.

How do I model this in Rust?

My current approach would be to define a trait and write different implementations of it. I would then pass around a boxed trait object (Box<dyn MyTrait>). I often find myself trying to combine this with some poor man's manual dependency injection.

This approach feels very object oriented and not native to the language. Would this be the recommended way of doing things or is there a better approach to take in Rust?

Thanks in advance!

view more: next ›