Rust doesn’t have the concept of a constructor in the sense of C++, C#, Java etc. You create new data structures by simply using the following syntax
struct Point {
x: i32,
y: i32
}
let pt = Point { x: 10, y: 20 };
However, by convention you might create an impl to create/initialize your structures. Rust code, by convention suggests such functions be named new. For example
impl Point {
pub fn new() -> Point {
Point {
x: 0,
y: 0
}
}
}
let pt = Point::new();
Ofcourse, we might declare parameters/arguments on the function just like any other functions.