Continuing the discussion from Bikeshed: Rename `catch` blocks to `fallible` blocks:
C++ there’s clear distinction in the syntax between passing things by reference (pointer) and by value, but there’s no distinction between owned and borrowed values.
In Rust it’s the opposite. The syntax exists to separate borrowed vs owned, but the distinction between values and pointers is vague, and handled entirely differently (
& may be a 2-usize struct, but
Box is just a raw pointer, usually).
C is super explicit about dereferencing, but the concept of lifetimes is left entirely up to programmer’s imagination.
OTOH Rust is explicit about borrows and lifetimes, but dereferencing is often hidden.
So given all that if you think Rust reference == C pointer, you’ll think of them from a completely wrong perspective.
For example, in C it’s common to return objects by pointer, because that’s how
malloc works, and there’s no other way to have any private type than via an opaque struct pointer. But in Rust if you try to allocate something and return a reference to it the borrow checker will tell you it doesn’t make any sense.
In C it’s usual to put pointers in structs. In Rust references in structs is are a special case of limited usefulness.
So I think it’s better to think of Rust’s references as temporary read/write locks that are implemented at compile time. That fixes thinking from “I want to return this by pointer” to “why would I give a temporary read-only lock to the object, rather than the object itself?”