6 ms·
Rust does have some new syntax, but I think most of it is justified for making programming in it nicer. The `~[u8]` would be written `std::unique_ptr<u8>` in C
by mcpherrinm 13y ago
Rust does have some new syntax, but I think most of it is justified for making programming in it nicer.
The `~[u8]` would be written `std::unique_ptr<u8>` in C++. They're used everywhere in Rust, and having to write out unique_ptr would get awfully tiresome.
The `acc` on its own line is a result of "the last statement gets returned" like many functional languages do. If you were writing C++, you'd write `return acc;` instead. This one is more of a convenience, and you could get away without it.
- masklinn 13y ago> The `~[u8]` would be written `std::unique_ptr<u8>` in C++. Wouldn't it be `std::unique_ptr<std::vector<u8>>`?
- mcpherrinm 13y agoIndeed, it would.
- userulluipeste 13y agoI agree that C++ broke the syntax terseness of C and become verbose for the sake of being explicit enough. This gets inconvenient sometimes, but the good thing is that it is a technical solvable problem - just redefine the long keywords or configure your editing tools to help you out typing.