Owned types manage their own memory and data, while borrowed types reference data owned by another variable without taking responsibility for it.
Owned types hold the data directly and are responsible for freeing it, while borrowed types hold a reference to data owned by someone else. Owned types like String or Vec<T> manage their own memory, whereas borrowed types like &str or &Vec<T> point to existing data without taking ownership.
fn main() {
let owned = String::from("hello");
let borrowed: &str = &owned;
println!("{owned}, {borrowed}");
}
Owned types are like owning a house; you are responsible for the entire structure and its maintenance. Borrowed types are like renting a room; you can use the space, but you don't own the building and must follow the owner's rules. You use ownership when you need to create and manage data, and borrowing when you just need to read or temporarily use data that already exists.