Hello World, but not every time!

When I work with C I have a template-file with some basic #include’s, #define’s and a int main(… I always use. Not very important, but I find it efficient.

When I start a project with cargo new it always starts with code to say ‘Hello World”. Funny, but exactly never useful. Is there an easy way to replace that code with a template of my own?

Here's a topic with the same question: How to set a cargo new template?

1 Like

I may not understand that topic enough, but I think that it gives a complicated solution for a simpel thing: the Hello World code cargo opens with, must reside somewhere. All I want is to replace that.

The HW-code is probably here.

1 Like

To solve the general case you can use something like cookiecutter. Though I've personally never used it (in any language), I prefer to make proper packages and add them as dependencies.

yes, that's possible, as pointed out already.

but there's also alternatives to cargo new. for instance, how about

cargo generate my-favorite-template


cargo scaffold my-other-favorite-template

1 Like

Thanks! And my apologies for my dumbness :slight_smile:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.