So again, we could very easily keep everything in mind because this will be a small program.
But let's take a quick minute to implement good practice and place our code in another file and then
we will just have main.
All that code.
So let's create a new file inside of source called Find and Replace.
And in here is where we can store all of our logic.
So let's take all of this.
Cut it out here, paste it in here, and then let's take this function, cut it out of here, and also
put it in here.
And then we're going to create a public function called run, which is where we can take all of our
logic inside of main take it out and.
Place it inside of here.
So now we can come into main address and say mod find and replace.
And now we can just say find and replace.
Run.
And it's able to find it because run is public.
So all of that is good.
But now let's just make sure before we try running this, let's look at our our tree.
So remember, we can use cargo modules, generate tree, and then I want to generate mine with types
that I can see everything.
So we see we have our find and replace module.
We have our stuck in here private.
Great our print help function is private perfect.
And now our run function is public, which we then call inside of main.
So everything looks good.
So now let's run it.
Make sure our error message is is printed out.
And they are.
So now let's run it again with giving it four arguments.
And perfect.
So we're back at the same place we were prior to separating our code into a module.
So now we're right back to where we were and now we can continue on with handling our file logic.