I am currently using rustlearn to evaluate different classification models. The problem that I encountered is as follows:
trait Foo<T> {
fn bar(&self, x: T);
}
struct Baz;
struct Smth;
impl<'a> Foo<&'a Smth> for Baz {
fn bar(&self, x: &Smth) {}
}
fn main() {
let some_foo: Box<Baz> = Box::new(Baz {});
let x = Smth {};
some_foo.bar(&x);
}
While it is possible to enter some_foo
how Box<Baz>
, it is Box<Foo<&Smth>>
impossible to use it instead , as this will cause the compiler to complain about &x
which will be reset (at the end main
) while still occupying (at bar
). This (I think) is due to what is being x
created after some_foo
, so it x
falls to some_foo
. Moving a creature x
in such a way that it occurs before the creature some_foo
becomes a solution; but suppose this is not possible.
, some_foo: Box<Baz>
, some_foo: Box<Foo<&Smth>>
. ( )?
¹, , , .. model.fit(x, y)
, x, y
(X, Y)
.