From the course: Rust for Data Engineering

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Demo: Fruit salad CLI

Demo: Fruit salad CLI - Rust Tutorial

From the course: Rust for Data Engineering

Demo: Fruit salad CLI

- [Instructor] All right, here we have a Rust command line interface. It's very similar to, let's say, Python's argparse module. The idea here is to use a command line interface to give us a little bit more flexibility when we're building things. Now, let's go ahead and take a look first at the structure. So here, you see that there's a source and a lib and a main. So by default, in Rust, if you wanted to put some library code together, you don't need to do anything other than inside of source, create a lib.rs file. In this case, this is the lib.rs, and I would go through and I would put in my logic. So in this case, I expose the function, so I type in P-U-B, and this makes an item visible to others, And then I create a vec here. So this is pretty simple. I create a vector that includes strings inside, so I say vec string, and now you just go through here and you say to string, to string, to string, right to all of the…

Contents