Import Suggestions In VS Code?

I have rust-analyzer activated in vs code, but I still don't seem to get any import suggestions...

For some reason it doesn't give me any help where in a language like java or typescript you get super nice import hinting. :cry:

Is there an other extension of something I can add to get this? thanks!

Screen Shot 2023-04-04 at 11.26.05 AM

Just in general I have a hard time with imports in rust. ChatGpt seems to give me incorrect use statements very often... :joy:

I know that I need to use "Demuxer" and "DemuxerOptions" and I know they should be exported from somewhere in the symphonia crate... but I don't know how to find the correct path so I can actually use these Demuxer things. :thinking:

First, you probably shouldn't use ChatGPT in a language you're not already very familiar with. You won't be able to spot mistakes.

If you have the library in your dependencies list in your Cargo.toml, rust-analyzer should pick it up.

Then. The path for an item should be the same in your code as the one shown in the docs.

2 Likes

The problem is the sometimes the thing I need doesn't appear in the docs at all...

I am familiar with the language, just not the libraries.

For most rust libraries I've found there aren't many working examples provided, especially ones that can do a lot of different things like symphonia.

1 Like

In this case not appearing in the docs seems appropriate, as searching for "DemuxerOptions" in symphonia's docs and GitHub repository brings up zero results, and searching for 'symphonia "DemuxerOptions"' on Google brings up one result; this thread. Actually, just 'Rust "DemuxerOptions"' also only brings up this thread.

Since you mentioned ChatGPT, I'm guessing that these are nonexistent structs hallucinated by the chat bot. I asked it to write "an example of demuxing using Rust's symphonia library" and it dreamt up a Demuxer and a DemuxerBuilder, neither of which exist, alongside a host of other made up types and functions. Another way to say that you should be familiar with the language if you're going to use ChatGPT is that you need to be able to recognise when it's wrong (which is very often).

5 Likes

Are they hallucinated or are they just in another crate? I guess I am using the wrong ai tool to help me?

It is very frustrating that the crate docs is simply a statement that declares the crate can do everything audio related, but I can't find any example anywhere of how to do something as simple as read in an mp3 audio file and write it to another file...

'Rust "DemuxerBuilder"' has zero hits on Google, so I believe it doesn't exist at all. I think ChatGPT is more concerned with creating convincing, human-like text than factually correct output, though the two do overlap quite a bit.

I've tried using it a couple of times but I never had any success with it, whether it was for Rust, TypeScript or a rough pseudocode outline for an algorithm. I think it really depends on how many times it has seen the same or similar problems in its learning material. Another AI tool I've seen people use for programming is GitHub Copilot but I've never tried it myself.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.