3 ms·
Just so you’re clear about it, a Rust trait is not like a C struct. It is like a Java interface. Rust’s struct is like a C struct. “Trait” is used for similar
by steveklabnik 3y ago
Just so you’re clear about it, a Rust trait is not like a C struct. It is like a Java interface. Rust’s struct is like a C struct.
“Trait” is used for similar features in Scala and PHP. https://en.wikipedia.org/wiki/Trait_(computer_programming) https://en.wikipedia.org/wiki/Trait_(computer_programming)
Box is used in Java and many functional languages. https://en.wikipedia.org/wiki/Boxing_(computer_science) https://en.wikipedia.org/wiki/Boxing_(computer_science)
Arc is the most confusing name out of these for sure; most folks talk about “reference counting” in general and assume the count is atomic; with Rust’s performance and safety focus, Rc is the non-reference counted version and Arc is the atomically reference counted version. Additionally, there is a feature called “automatic reference counting” that some languages use, that uses atomic reference counting in the implementation.
> There's no special Google result for rust '
If I google for “rust apostrophe” this is my first result, which is pretty comprehensive: https://stackoverflow.com/questions/22048673/what-are-the-identifiers-denoted-with-a-single-apostrophe https://stackoverflow.com/questions/22048673/what-are-the-id...
While this syntax is unusual it is also not unique, OCaml uses it for similar purposes. Nobody loves this one, but also nobody was able to come up with something that could be agreed upon to be better.
- tialaramex 3y ago> Rc is the non-reference counted version and Arc is the atomically reference counted version. Typo here I think Steve, Rc is reference counted, but it's not atomically reference counted. Hence the lack of an A. You've managed to instead say that it's not reference counted.
- steveklabnik 3y agoThank you, yes. I think my phone was messing with me. Too late to edit now. I appreciate it.