By the way, it seems to me like you have presumptions about Rust and you are trying to use it as an object-oriented language without having consulted the documentation. For trivial things like this, you should read The Book.
I am actually reading the book and have been for the last 3 weeks. I'm learning the language and following other resources. But thank you for your reply.
This makes for a more consistent reading experience (people here are used to reading these code blocks), it allows copying of the code (so people answering your question can reproduce the error message in case that’s helpful with coming up with an answer), and it even ensures compatibility with other accessibility tooling such as screen readers.
Relevant place in the book for this information in particular is here, though the book is generally designed to be read linearly (possibly skipping the example project chapters). But hey… chapter 5 of 20 is not all that far in ^^
All functions defined within an impl block are called associated functions because they’re associated with the type named after the impl. We can define associated functions that don’t have self as their first parameter (and thus are not methods) because they don’t need an instance of the type to work with. We’ve already used one function like this: the String::from function that’s defined on the String type.
Associated functions that aren’t methods are often used for constructors that will return a new instance of the struct. These are often called new, but new isn’t a special name and isn’t built into the language. […]