How do you declare an interface in Rust?

Viewed 18283

I have multiple types with similar methods. I want to abstract over them by writing an interface, like I would in Java:

public interface Shape {
    public float area();
}

class Circle implements Shape {
    public float area() {
        return radius * radius * Math.PI;
    }

    public float radius;
}

However, there is no interface keyword in Rust. Doesn't Rust offer the possibility to abstract over multiple types?

1 Answers
Related