abrahambelch

joined 7 months ago
[–] [email protected] 14 points 5 days ago* (last edited 5 days ago)

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

[–] [email protected] 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.

[–] [email protected] 3 points 2 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!

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

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

[–] [email protected] 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

[–] [email protected] 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.

[–] [email protected] 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!

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

Thanks for your reply!

[–] [email protected] 6 points 1 month ago

Thanks for the advice! I didn't know generic functions were preferred. But it makes perfect sense if you think about it.

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

Thanks for the explanation! I think just using an enum will do perfectly well in my case.

30
Strategy Pattern in Rust (programming.dev)
submitted 1 month ago* (last edited 1 month ago) by [email protected] to c/[email protected]
 

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!

[–] [email protected] 10 points 1 month ago* (last edited 1 month ago) (1 children)

I'm able to speak German (native speaker) and English (fluent).


Also, as a German speaker, I'd like to correct the question in the post:

Formal would be "Welche Sprachen sprechen Sie?".

More fitting for a casual environment (such as Lemmy) would be "Welche Sprachen sprecht Ihr?" though :)

This is, because in German there are formal and informal ways of addressing people, both with their distinctive pronouns. Usually, when talking to people you don't know personally, you'll address them formally and then, when offered to, switch to the informal style once you know them. Online or among the younger generation it is much more common to just use the informal case though.

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

Now I get your point. Technically, I think it could be possible to only include the changes in Chrome. It would make sense for Google to push the changes all the way down to Chromium, though, as this would eliminate ad blockers on many competing browsers as well. Judging based on the past I would say this is what's gonna happen

view more: next ›