Rust for Data Engineering

01 - 1. Getting Started with the Modern Rust Development Ecosystem

01 - Meet the instructor and course overview


02 - Introduction to the AI coding paradigm shift

03 - Introduction to cloud-based development environments

02 - 2. Rust Sequences and Maps

01 - Introducing Rust sequences and maps

02 - Demo Print Rust data structures

cargo new print-data-structs

03 - Demo Vector fruit salad

/*
    This program creates a fruit salad by scrambling (shuffling)a list of fruit.
    A vector is a growable array.It can grow or shrink in size and is one of the most
    useful data structures in Rust.A vector is represented using the Vec<T>type.
*/
use rand::seq::SliceRandom;
use rand::thread_rng;

fn main() {
    let mut fruit = vec![
        "Orange",
        "Fig",
        "Pomegranate",
        "Cherry",
        "Apple",
        "Pear",
        "Peach",
    ];

    // Scramble (shuffle) the fruit - 打乱
    let mut rng = thread_rng();
    fruit.shuffle(&mut rng);

    // Print out the fruit salad
    println!("Fruit Salad:");
    for (i, item) in fruit.iter().enumerate() {
        if i != fruit.len() - 1 {
            print!("{}, ", item);
        } else {
            println!("{}", item);
        }
    }
}

04 - Demo VecDeque fruit salad

双端队列


  转载请注明: malred-blog Rust for Data Engineering

  目录