Answers for "rust trait inheritance"

1

rust trait inheritance

trait A {}
trait B: A {}

struct S;

impl B for S {}

// Commenting this line will result in a "trait bound unsatisfied" error
impl A for S {}

fn main() {
    let _x: &B = &S;
}
Posted by: Guest on May-20-2020

Browse Popular Code Answers by Language