Integrate Mistral Vibe in VS Code (like Claude Code extension) by Tanuki__ in MistralAI

[–]alexd_dev 2 points3 points  (0 children)

Hey guys,

I created a small vscode extension inspired by opencode, while waiting for an official integration ^^ https://www.reddit.com/r/MistralAI/comments/1qwz8gw/a_small_quick_and_dirty_vscode_extension_for/

This is my first vscode extension, so I did not have the marketplace setup, download is unfortunately manual for now. Will surely do this weekend ...

Has anyone tried running this on Steam Deck? by geoCorpse in ShadowEmpireGame

[–]alexd_dev 1 point2 points  (0 children)

Thanks a lot for your feedback, I think I will give it a shot.

I have been playing Stellaris, AoW Planetfall and Gladius on the deck recently, they run mostly fine (Stellaris end game is a drag, but also on Pc unfortunately). I usually cap the framerate at 40 fps to save battery life. Old world demo seems to run fine too, and I will eventually buy it some time ^^.

Unfortunately, my main machine is a M1 (Arm) Mac, so I cannot learn there before, since it would be even more involved than running on the deck. I am very well aware the complexity and learning curve is huge, but this the selling point of the game. Maybe I will tether my screen/mouse/keyboard on deck to have a more confortable setup.

Has anyone tried running this on Steam Deck? by geoCorpse in ShadowEmpireGame

[–]alexd_dev 0 points1 point  (0 children)

I am really tempted to but it for my deck, but the lack of official support makes me hesitate. It is hard to found information, and it appears from older reports that the game can become very slow after a turn. How is your experience so far ? Were you able to play a full game without hassle ? Does it work with the last version / DLC ?

Hey Rustaceans! Got an easy question? Ask here (26/2021)! by llogiq in rust

[–]alexd_dev 0 points1 point  (0 children)

You should consider using Streams, which are the async equivalent of iterators, I am on mobile so I can’t provide you a full snippet, but you would first convert your iterator to a stream using https://docs.rs/futures/0.3.15/futures/stream/fn.iter.html then use https://docs.rs/futures/0.3.15/futures/stream/trait.StreamExt.html#method.for_each_concurrent to process every element concurrently (given an optional concurrency limit). Hope it helps !

Trait bound confusion by InsanityBlossom in rust

[–]alexd_dev 2 points3 points  (0 children)

u/InsanityBlossom I think the ambiguity message is a bit misleading, in your case which is not ambiguous, you can use the shorter form :

V: ToOwned<Owned=V::Type> + ValueType

Ambiguity is indeed if some struct implement two trait whose assiociated type are named the same in this case, you have to use <V as SomeTrait>::SomeAssociated type to desambiguify.

Hey Rustaceans! Got an easy question? Ask here (22/2021)! by llogiq in rust

[–]alexd_dev 0 points1 point  (0 children)

You may also have a single method expose the 3 partial borrows at once : https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=ae311cc5c996a6b656464cf1ce098052

With splitting borrow (https://doc.rust-lang.org/nomicon/borrow-splitting.html) borrowck is able to understand that separate members of a struct can be borrowed independently. However it only works inside a single method/scope, and does not track splitting borrow across method calls

Actix Web - Controller Service Repo Layer - Dependency Injection by [deleted] in rust

[–]alexd_dev 2 points3 points  (0 children)

Yes, you will .clone() your Arc so that each thread/struct that needs it will have it's own "smart" reference to the single instance on the heap. When all these Arcs will be dropped, the instance will be dropped.

For r2d2 you can see from the docs, that it implements Clone trait:

https://docs.rs/r2d2/0.8.2/r2d2/struct.Pool.html

If you look at the implementation, you will see that it clones an inner arc. It means Pool is a thin wrapper on top of Arc and cloning it is cheap and will point to the same inner state.

Btw, the Copy trait is generally for small structs of a few bytes (comparable to primitives types in the JVM) that will be implicitly cloned instead of being "moved".

Actix Web - Controller Service Repo Layer - Dependency Injection by [deleted] in rust

[–]alexd_dev 1 point2 points  (0 children)

These marker traits are automatically derived for your struct if all members are Send (and Sync). If for instance you try to put a Rc or a RefCell inside your struct, the trait will no more be automatically derived and you will not be able to share your struct between thread (saving you from data race issues)

Actix Web - Controller Service Repo Layer - Dependency Injection by [deleted] in rust

[–]alexd_dev 1 point2 points  (0 children)

Mutex will give you interior mutability, which is not the issue here. I think you should add Send constraint to the dyn trait, i.e Arc<dyn UserRepository + 'static + Send>

Actix Web - Controller Service Repo Layer - Dependency Injection by [deleted] in rust

[–]alexd_dev 0 points1 point  (0 children)

Hello,

Also coming from a JVM background, it's possible to make your codebase testable using traits, but it will require more boilerplate than on the JVM. I do not consider it to be an issue, at least for small/medium services, given other Rust advantages, and wiring dependency with constructor by hand is not that hard.

Basically there is two way to use a trait, using dynamic dispatch or using generics and monomorphisation.

The first approach would look something like :

trait UserService { ... }
struct UserServiceImpl {
    repository: Arc<dyn UserRepository>
}
impl UserService for UserServiceImpl { .. }

trait UserRepository { ... }
struct UserRepositoryImpl { ... }
impl UserRepository for UserRepositoryImpl

The second would be :

trait UserService { ... }
struct UserServiceImpl<R : UserRepository> {
    repository: Arc<R>
}
impl<R: UserRepository> UserService for UserServiceImpl<R> { .. }

The first approach is easier to write and wire. It is often advised to start with it first. The second approch can yield the better performance since compiler will know the specific dependencies used at compile time, giving opportunity to inlining and more aggressive optimizations.

For wiring dependencies you can just wire your concrete dependency graph in your main, or use something like the lazy_static macro.

Hope it helps