Rust-in-replit fcc 4

hello, The instructions for fcc 4 do not work.

Task: Within the main function, declare a new variable, and name it firstName and give it a value of "<your_name>". Ensure to declare it before the println! call, and place your name within double quotes.

my code so far

fn main() {
  let firstName = "<your_name>";
  println!("Hello, world!");
}

outputs this:

  Compiling fcc-rust-in-replit v0.1.0 (/home/runner/Rust-in-Replit)
warning: unused variable: `firstName`
 --> calculator/src/main.rs:2:7
  |
2 |   let firstName = "<your_name>";
  |       ^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_firstName`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: variable `firstName` should have a snake case name
 --> calculator/src/main.rs:2:7
  |
2 |   let firstName = "<your_name>";
  |       ^^^^^^^^^ help: convert the identifier to snake case: `first_name`
  |
  = note: `#[warn(non_snake_case)]` on by default

warning: `fcc-rust-in-replit` (bin "calculator") generated 2 warnings
    Finished dev [unoptimized + debuginfo] target(s) in 0.70s
     Running `target/debug/calculator`
Hello, world!

so I also try the suggested:let _firstName = "<your_name>";
which gives me more trouble:

 cargo run --bin calculator
   Compiling fcc-rust-in-replit v0.1.0 (/home/runner/Rust-in-Replit)
warning: variable `_firstName` should have a snake case name
 --> calculator/src/main.rs:2:7
  |
2 |   let _firstName = "<your_name>";
  |       ^^^^^^^^^^ help: convert the identifier to snake case: `_first_name`
  |
  = note: `#[warn(non_snake_case)]` on by default

warning: `fcc-rust-in-replit` (bin "calculator") generated 1 warning
    Finished dev [unoptimized + debuginfo] target(s) in 0.73s
     Running `target/debug/calculator`
Hello, world!

The instructions say to declare a new variable(before the println call) and name it firstName and then give it a value of “<your_name>”, which I did. and then place your name within double quotes(but it does not say where to put that).
I decided to try:

fn main() {
  let firstName = "Myname";
  println!("Hello, world!");
}

which then outputs this:

warning: unused variable: `firstName`
 --> calculator/src/main.rs:2:7
  |
2 |   let firstName = "Myname";
  |       ^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_firstName`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: variable `firstName` should have a snake case name
 --> calculator/src/main.rs:2:7
  |
2 |   let firstName = "Myname";
  |       ^^^^^^^^^ help: convert the identifier to snake case: `first_name`
  |
  = note: `#[warn(non_snake_case)]` on by default

warning: `fcc-rust-in-replit` (bin "calculator") generated 2 warnings

I then tried the suggested fix:

fn main() {
 let first_name = "Myname";
 println!("Hello, world!");
}

which outputs this:

   Compiling fcc-rust-in-replit v0.1.0 (/home/runner/Rust-in-Replit)
warning: unused variable: `first_name`
 --> calculator/src/main.rs:2:7
  |
2 |   let first_name = "Myname";
  |       ^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_first_name`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: `fcc-rust-in-replit` (bin "calculator") generated 1 warning
    Finished dev [unoptimized + debuginfo] target(s) in 0.58s
     Running `target/debug/calculator`
Hello, world!

seems like we’re getting somewhere, right?
so then I tried this:

fn main() {
  let first_name = "Myname";
  println!("Hello, ", first_name, "!");
}

and this:

fn main() {
  let first_name = "Myname";
  println!("Hello, " + first_name, + "!");
}

The output tells me it expected , instead of + which is what I had just tried…

fn main() {
  let first_name = "Myname";
  println!("Hello, first_name !");
}

I have tried running fcc test 4, which gives me the same information, so matter what the code is.

Even though both of those conditions are satisfied already, it always reminds me to:

You should declare a variable `firstName` and give it a value of your first name within double quotes.

You should follow the compiler's advice to add a semi-colon at the end.

In a failed attempt to get some helpful output, I have tried adding a semicolon in a couple different places to no avail.
warns me about unused variables again, as expected.

So what gives? isn’t this supposed to be a beginner friendly tutorial here? obviously something is not clear.

Could you provide a link to the challenge that you are attempting?

no I do not have a link. I am logged in on replit and the url contains my personal info, so I will not copy it. you can easily get into the course by searching the title of this thread.

It is polite to provide relevant links when you are asking for help from people. The harder you make it to provide help, the less help you will get, in general.

Is this the course?

yes, that looks like the course, but that is not really a link to it, so I did not provide that one.

for someone who knows rust it should be possible to understand everything from the detailed output, am I wrong?

Yes, I actually, really need the link I asked for. I try not to ask for a link just to pointlessly torture people - that’s rude.

I can help you get something that works from what you posted alone, but I can’t see the intention of the step without actually seeing the code in the context of the course.

It was indeed necessary to ask for context. If you had followed the instructions in fcc 4, then you would have known the answer to your question.

It says that after trying to run the code and “seeing what the compiler says,” you should type fcc test 4 to see if you have successfully completed the challenge. The code from the very top of your first post had already passed the challenge. If you had followed the instructions, you would have seen that, and been able to proceed to fcc 5, which tells you why you got error messages and how to correct them.

The whole point is to get the errors to appear and then guide you in how to overcome them.

well certainly I do not want to be rude or torture anyone. but for some reason that I do not understand I cannot find any link to the course. maybe I can resign from the course and then replit will cough up a link for me. I would like to not try that.

The code in the beginning was simply this:

fn main() {
    println!("Hello, world!");
}

and the task was this:

Task: Within the main function, declare a new variable, and name it firstName and give it a value of "<your_name>". Ensure to declare it before the println! call, and place your name within double quotes.

the test command returns this(no matter what the code is):

 fcc test 4

You should declare a variable `firstName` and give it a value of your first name within double quotes.


You should follow the compiler's advice to add a semi-colon at the end.

Please see my post above.

the code at the top of my first post could not have passed, since the requirements had not yet been satisfied.
Task: Within the main function, declare a new variable, and name it firstName and give it a value of "<your_name>". Ensure to declare it before the println! call, and place your name within double quotes.
as you can see, it says to “place your name within double quotes”. the code at the top of my first post code did not have that.

That’s what I was saying - when I ask for more information, it is because I think it helps me answer your question. I’m not trying to be rude, gatekeep the knowledge, or torture you with pointless tasks.

I am clearly not reading well today since I now see there is a method to retrieve the solution when stuck. I’m sorry about that. @bvanb, now I see their solution, it seem that at some point (probably near the top as you said) I did have the right answer.
However, since the test did not test anything, it was quite confusing. I would venture to suggest changing the command test to hint or something. like that.
I was happy with the compiler warning me and moving on, but not when I had no idea if my solution was correct.

Ah, yeah, I’m starting to remember this course better. Listening to the compiler is a huge piece of writing Rust, so this course tries to walk you through how to interpret and implement compiler suggestions.

thanks. I appreciate any help on my journey. sometimes it takes others to make me see what’s already there. I had the correct solution(for a minute) but there was no way to confirm it was correct without viewing the solution. I had previously assumed the purpose of the test function was to “test” for correctness. I hope I won’t be making that mistake again soon.

Hello there,

Just to add more information about these lessons:

If there is a test (the description/instructions will tell you), then you are expected to run fcc test <n> to tell if you have passed. If you have passed, the output will say as much - there will be no hint.

Sometimes, you will pass the test, and the program will not compile. This is expected. You have still achieved the goal of the lesson.

It seems you understand where you went wrong in the first post, but, to clarify:

This lesson just expects you to see what the compiler says about your code after the first task. This is made more clear as it continues in the next few lessons.


This all said, the tests are not robust. As it is difficult to test code that might/does not compile, many of the tests rely on RegEx which is difficult to cover all cases with.

Hope you do get something out of this course, though.

Thanks for your comments.
So far I’ve done a few lessons that didn’t seem to say what was needed but generally freeCodeCamp is really great and I love it, since it allowed me to begin at zero.
I have been working through the rust book, very slowly, as time allows, but I really like this replit approach and I’m sure I will get something out of it, regardless of how long I take.