this post was submitted on 10 Nov 2024
1 points (100.0% liked)

Rust

5989 readers
6 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

[email protected]

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 1 year ago
MODERATORS
 

In order to share the running transaction into a DAO style data management class, I have wrapped the transaction in an Arc and pass it into the DAO.

The issue is, once the transaction is in there I cannot call commit() on it because it cannot be moved out of the Arc anymore, as the commit requires a mut self.

Any ideas on how to work around this?

you are viewing a single comment's thread
view the rest of the comments
[โ€“] [email protected] 0 points 5 days ago (1 children)

It is now quite clear that I have to let go of OO paradigms. Maybe the package approach is perfectly fine.

Thank you for the insights and useful answer!

I have the idea that I am still only scratching the surface of rust, although I seem to manage it better every day.

As long as I leave my OO hat on the rack ๐Ÿ˜‰

[โ€“] [email protected] 0 points 5 days ago (1 children)

Definitely let go. Rust has some OOP features, but it's mostly just the OOP idea of interfaces, which Rust models with traits. You can also do dynamic dispatch, which is another OOP feature, but you should almost never use this in Rust unless you absolutely have to. Then there's encapsulation which is hugely important in Rust too, but yea outside of that kind of thing, I don't think OOP patterns are too useful. Honestly, if you ask me, many of these "OOP patterns" are really just solving problems that OOP causes in the first place.

Feel free to ask any other questions.

[โ€“] [email protected] 0 points 5 days ago

Thank you again and I will.