[Rust] Tuples in Rust

Learn how to represent multiple values of different type using a single type by leveraging the power of tuples in Rust.

 

#[allow(warnings)]

fn main() {
    let point = ("A", 32, 34);
    println!("Point {}: {}, {}", point.0, point.1, point.2);
    
    let text = "Hello world!";
    let (head, tail) = text.split_at(5);
    println!("{}{}", head, tail);
}

 

posted @ 2024-02-20 02:32  Zhentiw  阅读(4)  评论(0编辑  收藏  举报