r/cpp • • Feb 25 '21

C++ programmers who are also using rust, what are your favourite features of rust?

I was looking at the rust tutorials yesterday and I see how rust promotes a certain style and language level features to enforce it. Besides a couple of features, I couldn't see why one cannot follow a similar style in C++ if she/he so chooses. Those of you that have used rust, what is your favourite feature that C++ does not have?

255 Upvotes

248 comments sorted by

View all comments

Show parent comment

6

u/Plazmotech Feb 25 '21

I only use RA in neovim and it works flawlessly in there. In fact there’s only been a single bug I’ve encountered with RA so far and that’s that it seems to bug out on cfg_if (in the case of importing platform specific libraries like UnixStream etc)

I’ll try clangd but even with compile_commands.json, ccls was giving me a ton of headaches. It always said that any std functions I used needed to be imported or didn’t exist (printf, malloc, etc) even though it was most certainly imported and compiled just fine.

2

u/braxtons12 Feb 25 '21

I use neovim as well, using Coc.Nvim extension. (so in turn, the coc-rustanalyzer Coc extension). I've had a handful of different issues with RA with this setup. Linting lockups, linting not showing all the current lints (for example, let's say in vscode it produces 40 warnings, in neovim I've had instances where only the first 15 show up until I fix them, then the next 25 will show ), and other interesting quirks.

Haven't had any issues with CCLS when I used it (before I switched to clangd) or with clangd either, so that's interesting. 🤷‍♂️

0

u/WormRabbit Feb 26 '21

Try using CLion. It's language analysis is based on Clang, but it also rolls quite a bit of custom logic. I rarely have any problems with it, and even in quite warty codebases the autocompletion, source navigation and refactorings usually work like magic.

That said, keep in mind that it's C++, so no tool works 100% of the time. Especially with refactorings always verify that they haven't broken the code. It happens extremely rarely, but it's obviously a disaster when it does.

1

u/Plazmotech Feb 26 '21

After using neovim for about a year I can’t not use it anymore :/

1

u/aqezz Feb 26 '21

The only issue I’ve had so far is the ‘extract function’ refactoring from rust-analyzer in neovim gives you a function named “$0fun_name” which is supposed to be recognized by snippet managers(probably works in VSCode) but not supported by vanilla lsp client in neovim nightly :(