diff --git a/.all-contributorsrc b/.all-contributorsrc
index d3f0c2ce..00566c7e 100644
--- a/.all-contributorsrc
+++ b/.all-contributorsrc
@@ -1155,6 +1155,78 @@
"contributions": [
"content"
]
+ },
+ {
+ "login": "rytheo",
+ "name": "Ryan Lowe",
+ "avatar_url": "https://avatars.githubusercontent.com/u/22184325?v=4",
+ "profile": "https://github.com/rytheo",
+ "contributions": [
+ "code"
+ ]
+ },
+ {
+ "login": "cuishuang",
+ "name": "cui fliter",
+ "avatar_url": "https://avatars.githubusercontent.com/u/15921519?v=4",
+ "profile": "http://www.dashen.tech",
+ "contributions": [
+ "content"
+ ]
+ },
+ {
+ "login": "luskwater",
+ "name": "Ron Lusk",
+ "avatar_url": "https://avatars.githubusercontent.com/u/42529?v=4",
+ "profile": "https://github.com/luskwater",
+ "contributions": [
+ "content"
+ ]
+ },
+ {
+ "login": "liby",
+ "name": "Bryan Lee",
+ "avatar_url": "https://avatars.githubusercontent.com/u/38807139?v=4",
+ "profile": "http://liby.github.io/liby/",
+ "contributions": [
+ "content"
+ ]
+ },
+ {
+ "login": "nandajavarma",
+ "name": "Nandaja Varma",
+ "avatar_url": "https://avatars.githubusercontent.com/u/2624550?v=4",
+ "profile": "http://nandaja.space",
+ "contributions": [
+ "doc"
+ ]
+ },
+ {
+ "login": "merelymyself",
+ "name": "pwygab",
+ "avatar_url": "https://avatars.githubusercontent.com/u/88221256?v=4",
+ "profile": "https://github.com/merelymyself",
+ "contributions": [
+ "code"
+ ]
+ },
+ {
+ "login": "lucasgrvarela",
+ "name": "Lucas Grigolon Varela",
+ "avatar_url": "https://avatars.githubusercontent.com/u/37870368?v=4",
+ "profile": "http://linkedin.com/in/lucasgrvarela",
+ "contributions": [
+ "content"
+ ]
+ },
+ {
+ "login": "bufo24",
+ "name": "Bufo",
+ "avatar_url": "https://avatars.githubusercontent.com/u/32884105?v=4",
+ "profile": "https://github.com/bufo24",
+ "contributions": [
+ "content"
+ ]
}
],
"contributorsPerLine": 8,
diff --git a/.gitpod.yml b/.gitpod.yml
index 46b1a6a8..73cb802d 100644
--- a/.gitpod.yml
+++ b/.gitpod.yml
@@ -4,4 +4,4 @@ tasks:
vscode:
extensions:
- - rust-lang.rust@0.7.8:CvNqMTgDdt3UXt+6BCDTVg==
+ - rust-lang.rust@0.7.8
diff --git a/AUTHORS.md b/AUTHORS.md
index 9b388bb4..a4b6bdf2 100644
--- a/AUTHORS.md
+++ b/AUTHORS.md
@@ -165,6 +165,16 @@ authors.
stevenfukase 🖋 |
J-S-Kim 🖋 |
Fointard 🖋 |
+ Ryan Lowe 💻 |
+ cui fliter 🖋 |
+ Ron Lusk 🖋 |
+
+
+ Bryan Lee 🖋 |
+ Nandaja Varma 📖 |
+ pwygab 💻 |
+ Lucas Grigolon Varela 🖋 |
+ Bufo 🖋 |
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e857e339..1fc12506 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -285,7 +285,7 @@
#### Features
* add Option2 exercise (#290) ([86b5c08b](https://github.com/rust-lang/rustlings/commit/86b5c08b9bea1576127a7c5f599f5752072c087d))
-* add excercise for option (#282) ([135e5d47](https://github.com/rust-lang/rustlings/commit/135e5d47a7c395aece6f6022117fb20c82f2d3d4))
+* add exercise for option (#282) ([135e5d47](https://github.com/rust-lang/rustlings/commit/135e5d47a7c395aece6f6022117fb20c82f2d3d4))
* add new exercises for generics (#280) ([76be5e4e](https://github.com/rust-lang/rustlings/commit/76be5e4e991160f5fd9093f03ee2ba260e8f7229))
* **ci:** add buildkite config ([b049fa2c](https://github.com/rust-lang/rustlings/commit/b049fa2c84dba0f0c8906ac44e28fd45fba51a71))
diff --git a/README.md b/README.md
index 876578ee..dd96a59c 100644
--- a/README.md
+++ b/README.md
@@ -21,9 +21,9 @@ You will need to have Rust installed. You can get it by visiting https://rustup.
Just run:
```bash
-curl -L https://git.io/install-rustlings | bash
+curl -L https://raw.githubusercontent.com/rust-lang/rustlings/main/install.sh | bash
# Or if you want it to be installed to a different path:
-curl -L https://git.io/install-rustlings | bash -s mypath/
+curl -L https://raw.githubusercontent.com/rust-lang/rustlings/main/install.sh | bash -s mypath/
```
This will install Rustlings and give you access to the `rustlings` command. Run it to get started!
@@ -39,7 +39,7 @@ Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Then, you can run:
```ps1
-Start-BitsTransfer -Source https://git.io/JTL5v -Destination $env:TMP/install_rustlings.ps1; Unblock-File $env:TMP/install_rustlings.ps1; Invoke-Expression $env:TMP/install_rustlings.ps1
+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
```
To install Rustlings. Same as on MacOS/Linux, you will have access to the `rustlings` command after it.
@@ -50,15 +50,15 @@ When you get a permission denied message then you have to exclude the directory
[Run on Repl.it](https://repl.it/github/rust-lang/rustlings)
-[Open in Gitpod](https://gitpod.io/#https://github.com/rust-lang/rustlings)
+[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/rust-lang/rustlings)
## Manually
Basically: Clone the repository at the latest tag, run `cargo install`.
```bash
-# find out the latest version at https://github.com/rust-lang/rustlings/releases/latest (on edit 4.6.0)
-git clone -b 4.6.0 --depth 1 https://github.com/rust-lang/rustlings
+# find out the latest version at https://github.com/rust-lang/rustlings/releases/latest (on edit 4.7.1)
+git clone -b 4.7.1 --depth 1 https://github.com/rust-lang/rustlings
cd rustlings
cargo install --force --path .
```
diff --git a/info.toml b/info.toml
index 56fa7ec5..efe2b9c7 100644
--- a/info.toml
+++ b/info.toml
@@ -21,7 +21,7 @@ name = "variables1"
path = "exercises/variables/variables1.rs"
mode = "compile"
hint = """
-Hint: The declaration on line 12 is missing a keyword that is needed in Rust
+Hint: The declaration on line 8 is missing a keyword that is needed in Rust
to create a new variable binding."""
[[exercises]]
@@ -158,7 +158,7 @@ path = "exercises/if/if2.rs"
mode = "test"
hint = """
For that first compiler error, it's important in Rust that each conditional
-block return the same type! To get the tests passing, you will need a couple
+block returns the same type! To get the tests passing, you will need a couple
conditions checking different input values."""
# TEST 1
@@ -231,7 +231,7 @@ path = "exercises/move_semantics/move_semantics5.rs"
mode = "compile"
hint = """
Carefully reason about the range in which each mutable reference is in
-vogue. Does it help to update the value of referent (x) immediately after
+scope. Does it help to update the value of referent (x) immediately after
the mutable reference is taken? Read more about 'Mutable References'
in the book's section References and Borrowing':
https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html#mutable-references.
diff --git a/install.sh b/install.sh
index bf517851..f3b3f33d 100755
--- a/install.sh
+++ b/install.sh
@@ -25,12 +25,21 @@ else
exit 1
fi
+if [ -x "$(command -v rustup)" ]
+then
+ echo "SUCCESS: rustup is installed"
+else
+ echo "ERROR: rustup does not seem to be installed."
+ echo "Please download rustup using https://rustup.rs!"
+ exit 1
+fi
+
if [ -x "$(command -v rustc)" ]
then
echo "SUCCESS: Rust is installed"
else
echo "ERROR: Rust does not seem to be installed."
- echo "Please download Rust using https://rustup.rs!"
+ echo "Please download Rust using rustup!"
exit 1
fi
@@ -39,7 +48,7 @@ then
echo "SUCCESS: Cargo is installed"
else
echo "ERROR: Cargo does not seem to be installed."
- echo "Please download Rust and Cargo using https://rustup.rs!"
+ echo "Please download Rust and Cargo using rustup!"
exit 1
fi
@@ -75,6 +84,21 @@ function vercomp() {
then
max_len=$len2
fi
+
+ #pad right in short arr
+ if [[ len1 -gt len2 ]];
+ then
+ for ((i = len2; i < len1; i++));
+ do
+ v2[$i]=0
+ done
+ else
+ for ((i = len1; i < len2; i++));
+ do
+ v1[$i]=0
+ done
+ fi
+
for i in `seq 0 $max_len`
do
# Fill empty fields with zeros in v1
diff --git a/src/main.rs b/src/main.rs
index 83b98d96..af3dffbc 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -203,7 +203,7 @@ fn main() {
}
Subcommands::Verify(_subargs) => {
- verify(&exercises, verbose).unwrap_or_else(|_| std::process::exit(1));
+ verify(&exercises, (0, exercises.len()), verbose).unwrap_or_else(|_| std::process::exit(1));
}
Subcommands::Watch(_subargs) => match watch(&exercises, verbose) {
@@ -295,7 +295,7 @@ fn watch(exercises: &[Exercise], verbose: bool) -> notify::Result {
clear_screen();
let to_owned_hint = |t: &Exercise| t.hint.to_owned();
- let failed_exercise_hint = match verify(exercises.iter(), verbose) {
+ let failed_exercise_hint = match verify(exercises.iter(), (0, exercises.len()), verbose) {
Ok(_) => return Ok(WatchStatus::Finished),
Err(exercise) => Arc::new(Mutex::new(Some(to_owned_hint(exercise)))),
};
@@ -308,11 +308,11 @@ fn watch(exercises: &[Exercise], verbose: bool) -> notify::Result {
let filepath = b.as_path().canonicalize().unwrap();
let pending_exercises = exercises
.iter()
- .skip_while(|e| !filepath.ends_with(&e.path))
- // .filter(|e| filepath.ends_with(&e.path))
+ .find(|e| filepath.ends_with(&e.path)).into_iter()
.chain(exercises.iter().filter(|e| !e.looks_done() && !filepath.ends_with(&e.path)));
+ let num_done = exercises.iter().filter(|e| e.looks_done()).count();
clear_screen();
- match verify(pending_exercises, verbose) {
+ match verify(pending_exercises, (num_done, exercises.len()), verbose) {
Ok(_) => return Ok(WatchStatus::Finished),
Err(exercise) => {
let mut failed_exercise_hint = failed_exercise_hint.lock().unwrap();
diff --git a/src/verify.rs b/src/verify.rs
index eff57141..6f877831 100644
--- a/src/verify.rs
+++ b/src/verify.rs
@@ -1,6 +1,6 @@
use crate::exercise::{CompiledExercise, Exercise, Mode, State};
use console::style;
-use indicatif::ProgressBar;
+use indicatif::{ProgressBar, ProgressStyle};
use std::env;
// Verify that the provided container of Exercise objects
@@ -9,10 +9,18 @@ use std::env;
// If the Exercise being verified is a test, the verbose boolean
// determines whether or not the test harness outputs are displayed.
pub fn verify<'a>(
- start_at: impl IntoIterator- ,
+ exercises: impl IntoIterator
- ,
+ progress: (usize, usize),
verbose: bool,
) -> Result<(), &'a Exercise> {
- for exercise in start_at {
+ let (num_done, total) = progress;
+ let bar = ProgressBar::new(total as u64);
+ bar.set_style(ProgressStyle::default_bar()
+ .template("Progress: [{bar:60.green/red}] {pos}/{len}")
+ .progress_chars("#>-")
+ );
+ bar.set_position(num_done as u64);
+ for exercise in exercises {
let compile_result = match exercise.mode {
Mode::Test => compile_and_test(exercise, RunMode::Interactive, verbose),
Mode::Compile => compile_and_run_interactively(exercise),
@@ -21,6 +29,7 @@ pub fn verify<'a>(
if !compile_result.unwrap_or(false) {
return Err(exercise);
}
+ bar.inc(1);
}
Ok(())
}
@@ -45,7 +54,6 @@ fn compile_only(exercise: &Exercise) -> Result {
let _ = compile(exercise, &progress_bar)?;
progress_bar.finish_and_clear();
- success!("Successfully compiled {}!", exercise);
Ok(prompt_for_completion(exercise, None))
}
@@ -71,8 +79,6 @@ fn compile_and_run_interactively(exercise: &Exercise) -> Result {
}
};
- success!("Successfully ran {}!", exercise);
-
Ok(prompt_for_completion(exercise, Some(output.stdout)))
}
@@ -92,7 +98,6 @@ fn compile_and_test(exercise: &Exercise, run_mode: RunMode, verbose: bool) -> Re
if verbose {
println!("{}", output.stdout);
}
- success!("Successfully tested {}", &exercise);
if let RunMode::Interactive = run_mode {
Ok(prompt_for_completion(exercise, None))
} else {
@@ -138,6 +143,12 @@ fn prompt_for_completion(exercise: &Exercise, prompt_output: Option) ->
State::Pending(context) => context,
};
+ match exercise.mode {
+ Mode::Compile => success!("Successfully ran {}!", exercise),
+ Mode::Test => success!("Successfully tested {}!", exercise),
+ Mode::Clippy => success!("Successfully compiled {}!", exercise),
+ }
+
let no_emoji = env::var("NO_EMOJI").is_ok();
let clippy_success_msg = if no_emoji {