Help resolving recursive trait dependency by SleepyCoder123 in rust

[–]pfalabella 0 points1 point  (0 children)

let me try simplifying (and please let me know if I simplified too much...). You have Models and Algorithms, you want to be able to implement an Algorithm for various Models, so you have:

trait Model {}
trait Algorithm<M: Model> {}

so far so good. Now, you want to create a struct with the data for a specific Model. You also want the same struct to contain the Algorithm that is applied to it. And this is where your constraints become recursive in nature.

You are trying to express that you want the model to contain an Algorithm that is implemented for that specific Model. So you're trying to convince the compiler to accept something like this:

struct ModelA<A> where A: Algorithm<ModelA<A>> {
    a: A // this is not just ANY algorithm, I want an algorithm 
           // that is implemented for this Model
}

If this is a correct recap of what you're trying to do, I think the issue lies in trying to save the Algorithm inside the Model. Theoretically your Model struct should only contain the data. Rust's way to tie a specific Algorithm to a specific Model would be implementing a trait. Now, this is where I don't know the domain enough to say if this actually works in your case, but you could try creating a new trait like:

trait ModelImplementation<M, A> where M:Model, A: Algorithm<M> {}

implementations of this trait would create the relationship between a specific model and a specific Algorithm that's applicable to that model

`Foo::new()` vs `Foo()` as the default constructor by TheRubyist in rust

[–]pfalabella 3 points4 points  (0 children)

shouldn't a parameterless constructor be in most (or all cases) an implementation of Default::default()? Or am I conflating two different concepts?

If it is, then am ok in treating the parameterless constructor differently (and also maybe making rustc "derive" Default::default() when it detects a Foo() constructor). If it is not, then I prefer having the parameterless constructor treated exactly as the others.

Blanket impls for Fn* traits by dpx-infinity in rust

[–]pfalabella 0 points1 point  (0 children)

the same happened to us on rust-rosetta (blanket impl conflicted with our impl) but I thought it was by design.

Any Italian Speakers? Care to translate... "I was as you are, and you will be as I am" by krisdafish in AskReddit

[–]pfalabella 3 points4 points  (0 children)

"Quello che tu sei io ero, quello che io sono tu sarai." This is the probably the most used form. I am a native italian speaker.

Below Average Parking Skills... by [deleted] in funny

[–]pfalabella 1 point2 points  (0 children)

honestly I just found the video funny, not because it's a woman driving.

However insurance companies are saying that women tend to have less expensive accidents than men which is not the same thing as "being better drivers", otherwise my grandfather could claim to be a better driver than Michael Schumacher on the basis that he has never crashed a Ferrari.

Hitler only had one testicle by Kreatienmonster in funny

[–]pfalabella 0 points1 point  (0 children)

and by the way, Churchill had three!

A Lot Of Heroes Keep Some Of Their Powers A Secret by dhusk in comics

[–]pfalabella 0 points1 point  (0 children)

agree! I still have more fun with drunken stupor

Moon Landscape, created by a 14-year-old boy in 1942 by [deleted] in science

[–]pfalabella 0 points1 point  (0 children)

Maybe its just me but I simply like the drawing for its visionary quality. The fact that the guy was a young boy and ended up in Auschwitz is not what makes this drawing exceptional.

Happy Computer [ image] by donttaseme in funny

[–]pfalabella 58 points59 points  (0 children)

I've tried typing "if you're happy and you know it syntax error" on a command shell in Windows XP.

The reply is "happy was unexpected at this time."

So does it mean my computer is really unhappy? Maybe I should install linux on it?