Avatar ·

What is a "fat pointer" in Rust and why is it needed?

Hello, colleagues! I recently started learning Rust and came across the term "fat pointer". In the official documentation and on forums, this word appears, but the definitions are vague.\n\nI understand that in Rust there are regular pointers (for example, `*const T` or references `&T`) that simply store a memory address. But what is a "fat" pointer? How is it different from a regular one? I've heard that it's related to traits (`dyn Trait`) and slices (`&[u8]`).\n\nFor example, when I write:\n```rust\nlet slice: &[i32] = &[1, 2, 3];\n```\nI know that `slice` is a reference to an array. But they say it's a fat pointer. Why? After all, it's just a reference, isn't it? Or when I use a trait object:\n```rust\nfn print_debug(item: &dyn Debug) {\n println!("{:?}", item);\n}\n```\nHere `item` is also a fat po