rustbook-learning-guide 0.1.0

A comprehensive Rust learning guide with practical examples covering ownership, traits, polymorphism, and more
Documentation
//! Lifetime examples

pub fn lifetime_examples() {
    println!("\n⏰ Lifetime Examples");
    println!("{}", "-".repeat(21));
    
    let string1 = String::from("long string");
    let string2 = "short";
    
    let result = longest(&string1, string2);
    println!("Longest string: {}", result);
}

fn longest<'a>(x: &'a str, y: &'a str) -> &'a str {
    if x.len() > y.len() {
        x
    } else {
        y
    }
}