Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

`~` is just one pointer type; there's & and * also built-in to the language (and @, but that's moving to the standard lib); and Rust provides the control required for implementing arbitrary "smart-pointers" (e.g. reference counting is a library pointer).

~ is an owned pointer (like unique_ptr in C++); & is a "reference" or borrowed pointer (allowing access to data without taking ownership); * is a raw/unsafe pointer, and is identical to C's pointers.

Also, the * pointer doesn't conflict with multiplication because they can never occur in an ambiguous context:

  foo * bar = NULL; // C

  let bar: *Foo = std::ptr::null(); // Rust

  let bar = std::ptr::null(); // Rust, using type inference


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: