What is the difference between an owned value and a borrowed value in Rust?

In Rust, variables can be classified as either "owned" or "borrowed".

An "owned value" is a value that has a unique, exclusive ownership of the underlying data. When an owned value goes out of scope or is reassigned, the memory it occupies is automatically deallocated and freed. An example of an owned value is a variable declared using the keyword "let".

On the other hand, a "borrowed value" is a value that borrows the underlying data from an owned value. This means that it does not have exclusive ownership of the data and cannot deallocate it. Instead, it refers to the data of the owned value. A borrowed value can be created by passing a reference to an owned value using the "&" operator. A borrowed value can be read and used, but cannot be modified. This is because it does not own the data and cannot deallocate it.

In summary, an owned value is the one that has full ownership and control of the data, while a borrowed value is the one that only has a reference to the data and does not own it.