Understanding Owership in Rust

stack

use std::arch::asm;

fn main() {
    let s1 = String::from("hello");

    unsafe {
        asm!("int 3");
    }

    let (s2, len) = calculate_length(s1);
    println!("The length of '{s2}' is {len}.");
}

fn calculate_length(s: String) -> (String, usize) {
    let length = s.len();

    (s, length)
}