'Is this factory and how do I make constructor for struct?
struct Person{
name: String
}
fn person_factory(name: String)-> Person {
Person{
name,
}
}
fn main() {
let p1 = person_factory("Viktor Draganov".to_string());
println!("{}", p1.name);
}
Is this factory in rust? And how can I initialize person from constructor?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
