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.
Customize fruit salad with a CLI - Rust Tutorial
From the course: Rust for Data Engineering
Customize fruit salad with a CLI
- [Instructor] Here we have a example of a way to customize something in Rust by using a little bit of randomization here in this particular function that's in lib.rs. The code is going to take a mutable vector of strings as an input and return a new vector of strings that contains the same element as the input vector but the difference is it's a random order. So some of the unique things here about Rust, first of all is the pub keyword here. So what this does is it says that I can use this inside another module so it's publicly available so I can pull it into my main which is a great security default here. Also, the name here is pretty intuitive. You just do fn for function and then the inputs would include a mutable fruits which is a vector of strings and also the return type is a vector of strings. So what's really powerful about this style of programming in Rust is that we're able to explicitly say whether something is…