Today I saw this question about Rust (now deleted, screenshot attached for <10k). The problem in the question is that the variable is declared incorrectly (like C/C++ Type name;
instead of Rust's let name: Type;
). Now, variable declaration is a topic that in mentioned in chapter 2 of the official Rust book, and I doubt there is a resource teaching Rust that does not mention it. So this is clearly a case of someone that didn't even try to learn the language. What should we do with such questions? I'm tempted to close them, but I can't find a valid reason. Downvote of course, but close? Answer? Delete (after closing)?
-
1Presumably, there is a duplicate question on "how to declare a variable in rust", so close it as a dupe of that, and if you feel that the question lacked research effort downvote it. Conversely, if you think it was useful/helpful upvote it. Then move on.– Thom AJan 10 at 17:13
-
@Larnu Except there isn't such question (I checked).– Chayim FriedmanJan 10 at 17:13
-
3Then perhaps there should be! Sounds like the question is a good question, as we don't have that question yet, and a good answer could explain why what they tried didn't work, and what the correct syntax is.– Thom AJan 10 at 17:14
-
1What's wrong with such a question existing here? The whole purpose of this site is to be a knowledgebase of useful questions and answers. A question new users to a language have frequently would in fact be a useful question and answer.– Kevin BJan 10 at 17:19
-
@KevinB for years, it seemed to be the accepted wisdom that Stack Overflow was "not intended to replace existing documentation" etc. Now we've been left with many missing canonicals and many, many bad questions that could otherwise be duped to them.– Karl KnechtelJan 11 at 7:22
-
Re "there isn't such question": There is bound to be in some form. But it can be very hard to find such content. Search engines are of very little help these days.– Peter MortensenJan 12 at 2:13
-
The issue seems to be more that the author did look it up, but didn't understand any of it. That is a whole different ballgame, more of the "You might need to go to school for this" variety.– GimbyJan 16 at 15:16
2 Answers
If you think this will be useful to other people learning the language then answer it. However, there should already be a suitable duplicate for "How to declare a variable in Rust". If there isn't then there's your chance to create one.
If the question is unlikely to be helpful then just downvote and move on.
-
I searched for duplicates in the referred question, before it was deleted. All I could find was a combination of stackoverflow.com/questions/32180684/… with stackoverflow.com/questions/73432621/…. Searching for duplicates is hard, even in this tag, but I agree that it's the right thing to do.– E net4Jan 10 at 17:28
-
1The problem I've identified is that for questions like this, there will be perhaps hundreds of attempts by clueless beginners to ask the question, but none of them is good enough to function as a canonical - and editing them enough to put them in that shape, would require stomping on authorial intent (after all, the beginner's authorial intent is to make some specific piece of code work, not to provide the exposition for a how-to guide). Jan 11 at 7:24
-
A more SO-quality question, which this could be closed as dupe of, is "What are the parts of a variable declaration in Rust?" May 24 at 17:39
If the user "tried to learn" (did(n't) demonstrate research effort) is a reason to upvote/downvote but it's not a reason to close. A reason to close is that the question is unclear, off-topic or a duplicate. For the question you describe, one would expect a duplicate question, however, you state in the comments that there is no such duplicate. In my opinion, therefore, this has all the makings of a good question:
- The question hasn't been asked before
- It's concise and clear what the OP is trying to do
- They've shown their attempts
The fact that there is no duplicate candidate means that this is a great time to make it that duplicate candidate. So answer the question, explaining what the mistake was that they did (that they've tried to use C# style declaration) and that the syntax for Rust is let name: Type;
. Link to the documentation in your answer as well, so readers have a path to learn more if they want.
This'll then become an excellent question and answer for many to read in the future, hopefully attracting a wealth of upvotes.
It is therefore very unfortunate that the OP deleted their post.