Using 'hint` watch subcommand

In the rustling exercices they mention for each exercise the comment: (here for the if1 exercise):

// Execute rustlings hint if1 or use the hint watch subcommand for a hint.

How and where do I have to "give this command" to get hints???

(yeah, I am very very beginner level)

Judging from the instructions on the rustlings GitHub page, it looks like the command is installed globally? I'm not sure.

If that doesn't help, a few questions:

  • What platform are you using?
  • Are you doing this locally, or in one of the browser environments?
  • Do you know how to use a terminal/command prompt?

Using your teminal, cd into the rustlings directory and type.

rustlings hint if1

You should get something like this

It's possible to do this in one line if you would like!
Some similar examples from other languages:
- In C(++) this would be: `a > b ? a : b`
- In Python this would be:  `a if a > b else b`
Remember in Rust that:
- the `if` condition does not need to be surrounded by parentheses
- `if`/`else` conditionals are expressions
- Each condition is followed by a `{}` block.

or just do

rustlings watch

and after the errors..

Progress: [#>----------------------------------------------------------] 2/96 (2.1 %)                     ⚠️  Compiling of exercises/variables/variables1.rs failed! Please try again. Here's the output:
error[E0425]: cannot find value `x` in this scope
  --> exercises/variables/variables1.rs:11:5
   
<<SNIP>>

For more information about this error, try `rustc --explain E0425`.

Welcome to watch mode! You can type 'help' to get an overview of the commands you can use here.
hint
The declaration in the first line in the main function is missing a keyword
that is needed in Rust to create a new variable binding.

When in the "rustlings watch" command, you can now enter commands.. This is where you just type "hint" I suggest instead of "hint" type "help" and see what other commands "rustlings watch" offers.

help
Commands available to you in watch mode:
  hint   - prints the current exercise's hint
  clear  - clears the screen
  quit   - quits watch mode
  !<cmd> - executes a command, like `!rustc --explain E0381`
  help   - displays this help message

Watch mode automatically re-evaluates the current exercise
when you edit a file's contents.

Welcome. I ,although I have been programming forever, am also very beginner. Probably apparent from my only being at rustlings variables1. (note: I have been through it before..more than once...)

What are your interests in programming. Do you have something in mind you want to create?

I copied the exercices on my laptop, and then using VS Code I created a project Rustlings, and then I copy the .rs exercise file in VSC and start exercising :slight_smile:
I did run a command "rustup update" and it did execute an update. But that didn't change anything else.
the command 'rustlings' is unknown command.
Also in CML unknown

As to what kind of applicatoin I want to code, I don't know yet. First try to learn the basics of this RUST. (BTW, I did some coding in my previous life: Fortran (yeah, that was 45 years ago...), Basic, Dbase2, Python. These languages are rather simple to understand.

Okay, what am I missing here?

And BTW, thanks for your kind assistance! (DanielKeep and Stonerfish)

this is what I get in VS code:
PS C:\Users\axelh\rustlings> rustlings watch
rustlings : The term 'rustlings' is not recognized as the name of a
cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the
path is correct and try again.
At line:1 char:1

  • rustlings watch
  •   + CategoryInfo          : ObjectNotFound: (rustlings:String) [],  
      CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException

That doesn't match the installation instructions for rustlings. It looks like you are attempting a manual install, so you need to make sure you've cloned the entire repository and then run the cargo install --path . command. You may also need to ensure the directory cargo installs to is on your PATH so commands there can be seen.

I feel rustlings works better in a plain terminal.

Okay folks, based on the various replies, I decided to reinstall from scratch. Deleted the rustlings directory and the ran the following installation instructions with PowerShell.
In PowerShell (Run as Administrator), set ExecutionPolicy to RemoteSigned:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Then, you can run:
Start-BitsTransfer -Source https://raw.githubusercontent.com/rust-lang/rustlings/main/install.ps1 -Destination $env:TMP/install_rustlings.ps1; Unblock-File $env:TMP/install_rustlings.ps1; Invoke-Expression $env:TMP/install_rustlings.ps1

It's working as intended. Sorry for bothering y'all!

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.