Answer the question
In order to leave comments, you need to log in
How to make rustc clone dynamic type variables?
I started to get acquainted with rust and I can't understand "the vaunted magic of traits" in any way.
The task is simple, I want a structure with a dynamic type, for example i32 or f64. Rust doesn't know the size of T and can't copy it.. that's OK!
The book describes an example of using trait with an explicit data type.
Answer the question
In order to leave comments, you need to log in
(No need to throw the code with a picture)
MCVE for your error looks like this:
fn foo<T>(a: T) -> (T, T) {
(a, a)
}
fn main() {
foo(1);
}
fn foo<T: Copy>(a: T) -> (T, T) {
(a, a)
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question