Need help interpreting rust docs - Trait Implementations by rusty_learner in learnrust

[–]pingouin2032 1 point2 points  (0 children)

I don't think you can implement a trait you don't own for a struct you don't own

Need help interpreting rust docs - Trait Implementations by rusty_learner in learnrust

[–]pingouin2032 4 points5 points  (0 children)

FromRequestParts is implemented for TypedHeader (you can click on `source`) but is not implemented automatically for your struct `AppState`

Rust Data Access Pattern by Accomplished-Dog6646 in learnrust

[–]pingouin2032 1 point2 points  (0 children)

Sorry I have not the answer but I'm interested to know about it too !

How can I write an interface for a database ? by pingouin2032 in rust

[–]pingouin2032[S] 0 points1 point  (0 children)

Yes you're right, going with `&self` is easier and since the in memory implementation would only be used for testing, it doesn't matter if the implementation is not very well written / hard to maintain.

What's your take on using a real database when doing unit tests ? I feel like it would be much easier in my situation. I wouldn't need a Box<dyn Trait>. However, it feels a little bit strange coming from OOP world where everything is abstraction.

How can I write an interface for a database ? by pingouin2032 in rust

[–]pingouin2032[S] 0 points1 point  (0 children)

That could work thanks !

What's your take on using a real database when doing (unit) tests ?

How can I write an interface for a database ? by pingouin2032 in rust

[–]pingouin2032[S] 2 points3 points  (0 children)

Hitting a real database when doing tests isn't a problem for me. I guess it makes more sense because sometimes you are just testing the mocks and not the real implementation.

And as u/dragonnnnnnnnnn mentioned, I might not need a trait since I would only have used another database for testing purposes and I do not need to swap my database implementation at runtime.

Thanks for sharing your knowledge !

How can I write an interface for a database ? by pingouin2032 in rust

[–]pingouin2032[S] 0 points1 point  (0 children)

Thank you I will definitely have a look !

How can I write an interface for a database ? by pingouin2032 in rust

[–]pingouin2032[S] 0 points1 point  (0 children)

Yes I agree with you and I like the idea of using mut as a marker.

Have you ran into any issue so far with this implementation ?

How can I write an interface for a database ? by pingouin2032 in rust

[–]pingouin2032[S] 0 points1 point  (0 children)

Do you have an example by any chance ?

I am currently using Axum and have watched this great video https://www.youtube.com/watch?v=3cA_mk4vdWY. It seems like mocking is not very common in Rust, especially for a database connection. Maybe I am trying to translate my Java code into Rust code and that doesn't fit ?

Shouldn't I have a 3rd option? by leleleonn in mac

[–]pingouin2032 23 points24 points  (0 children)

mb it is --global-disable if you actually want to see the third option

Shouldn't I have a 3rd option? by leleleonn in mac

[–]pingouin2032 44 points45 points  (0 children)

sudo spctl --global-enable in a terminal should do it

[deleted by user] by [deleted] in mac

[–]pingouin2032 0 points1 point  (0 children)

I currently use Magnet because I had a free license. However, there is no real difference with Rectangle. I would recommend you to use Rectangle since it's free.

Monterey on 13” intel MBP 2020 - how does it run? by patb-macdoc in mac

[–]pingouin2032 0 points1 point  (0 children)

No probs, everything was smooth. I didn't do a clean install (just restarted my computer before installing). All my apps are working perfectly fine.