So i have this code:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=bee1747f8a1333d012f5ceb0ddb04b86
I'm trying to get a feel for how to use trait bounds and generics especially when something is not defined in the same mod.
I tried to look at the rustbook example of a trait bound, but I don't see the mistake right now.
I'm not sure why line 54/55 dont work.
Those are the lines in question and the error i get
pub fn getDoSomething<T>() -> DoSomething<T> where T:Repository{
DoSomething::new(RealRepo::new())
}
It says:
error[E0308]: mismatched types
--> src/main.rs:55:26
|
54 | pub fn getDoSomething<T>() -> DoSomething<T> where T:Repository{
| - this type parameter
55 | DoSomething::new(RealRepo::new())
| ---------------- ^^^^^^^^^^^^^^^ expected type parameter `T`, found struct `RealRepo`
| |
| arguments to this function are incorrect
|
= note: expected type parameter `T`
found struct `RealRepo<'_>`
note: associated function defined here
--> src/main.rs:23:16
|
23 | pub fn new(repository: T) -> Self {
| ^^^ -------------
Could you help me please?