rust armanriazi error value used here after move

In Rust, the error "value used here after move" occurs when you try to use a value after it has been moved to another location in memory. This error is a result of Rust's ownership system, which ensures memory safety by preventing the use of moved values.

To fix this error, you need to ensure that you don't use a value after it has been moved. One way to do this is by using references instead of moving the value. By using references, you can borrow the value without taking ownership of it.

Here's an example that demonstrates this error and how to fix it:

fn main() {
    let x = vec![1, 2, 3];
    let y = x; // x is moved to y

    println!("{:?}", x); // This line will cause the "value used here after move" error

    // To fix the error, you can use a reference to borrow the value instead
    let x = vec![1, 2, 3];
    let y = &x;

    println!("{:?}", x); // Now this line is valid because we're using a reference to x
}

In this example, the first usage of x after it has been moved to y will result in the error. However, in the second example, we use a reference &x to borrow the value of x, allowing us to print it without any issues.

Remember that using references instead of moving values is a fundamental concept in Rust's ownership system, and it helps ensure memory safety and prevent dangling references.