Convert the const to a Vector of String-type Vectors
Create a Place-holder Module/Function for Converting the const To a Vector of String-type Vectors
Now that we have simplified the creation/storage/retrieval of our graphic images, let's make the processing of those images easier, by converting the const value into a vector of String-type vectors.
Below are the changes we'll make to our "main.rs" file. We're being a little bit verbose with our symbol names, but this verbosity helps to document what's going on.
Notice that instead of putting the "str_to_vecvecstring()" function in our "main.rs" file, we're putting it into its own separate "convert_to_vec.rs" file ("module", essentially). The only reasons we are doing it this way is to keep the "main.rs" file clean, and to separate more cleanly the various tasks we're doing.
We're currently only printing the resulting image variable using the debug formatter ("{:?}"), because the standard println!() formatter will choke on trying to print a vector. We're not interested at this moment in pretty output, but we just want to make sure our processes are working.
Of course, this means we have to create the new "convert_to_vec" module. We'll start out with just a place-holder function that tests the basic process; we'll complete it later. For now, create the file and fill it with the following:
The new function first displays the &str it gets (named "incoming_str"), just to test our functionality; this will display the four frames of the plane. Then it converts that &str to a vector of vectors, which it returns to the "main()" function, which prints that vector of vectors using the debug formatter, which results in a jumble of plane parts being displayed.
Now that we've proven we are getting the string into our function successfully, we no longer need that test line:
Create a Module/Function to Properly Display the Vector of String-type Vectors
Here's the change we'll need to make to our "main()" function:
And here's our new module/file:
When you run this, you should see two copies of your chosen image; the first is as a single &str-type of data, and the second is as a vector of String-type vectors.
But, that vector of String-type vectors only has one inner vector, which contains all the frames of the image. We instead need one inner vector for each frame of the image. So we'll need to return back to the function we started above, and finish it.
Finish the Function for Converting the const To a Vector of String-type Vectors
Replace our entire "src/convert_to_vec" file with the following:
Now let's do the actual full conversion.
When you run this, you should see all the frames of your chosen image, numbered.