&impl or &dyn

107 points Seriy0904 36 comments

I am a newbie in rust. I've been reading some stuff regarding traits, and I seem to be confused what is the difference between this:

fn print_area(shape: &dyn Shape) {
    println!("Area: {}", shape.area());
}

And this :

fn print_area(shape: &impl Shape) {
    println!("Area: {}", shape.area());
}