You cannot skip or take ownership of a value in Rust without explicitly moving it or cloning it, as ownership rules prevent use-after-move errors. To skip using a value after passing it to a function, you must either clone it if it implements Clone or restructure your code to avoid the move.
fn main() {
let s = String::from("hello");
let s_clone = s.clone(); // Skip the move by cloning
takes_ownership(s_clone);
println!("{s}"); // s is still valid here
}
fn takes_ownership(some_string: String) {
println!("{some_string}");
}
If you want to skip the move entirely and just use the value, ensure the function takes a reference (&String) instead of ownership (String).