mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-11 13:19:18 +00:00
Merge branch 'main' of https://github.com/rust-lang/rustlings into rust-lang-main
This commit is contained in:
commit
1fad3083cd
@ -1884,6 +1884,42 @@
|
|||||||
"contributions": [
|
"contributions": [
|
||||||
"infra"
|
"infra"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"login": "nidhalmessaoudi",
|
||||||
|
"name": "Nidhal Messaoudi",
|
||||||
|
"avatar_url": "https://avatars.githubusercontent.com/u/63377412?v=4",
|
||||||
|
"profile": "https://nidhalmessaoudi.herokuapp.com",
|
||||||
|
"contributions": [
|
||||||
|
"code"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"login": "MahdiBM",
|
||||||
|
"name": "Mahdi Bahrami",
|
||||||
|
"avatar_url": "https://avatars.githubusercontent.com/u/54685446?v=4",
|
||||||
|
"profile": "https://github.com/MahdiBM",
|
||||||
|
"contributions": [
|
||||||
|
"tool"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"login": "Nagidal",
|
||||||
|
"name": "Nagidal",
|
||||||
|
"avatar_url": "https://avatars.githubusercontent.com/u/7075397?v=4",
|
||||||
|
"profile": "https://github.com/Nagidal",
|
||||||
|
"contributions": [
|
||||||
|
"content"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"login": "adamhb123",
|
||||||
|
"name": "Adam Brewer",
|
||||||
|
"avatar_url": "https://avatars.githubusercontent.com/u/25161597?v=4",
|
||||||
|
"profile": "https://adabrew.com",
|
||||||
|
"contributions": [
|
||||||
|
"content"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"contributorsPerLine": 8,
|
"contributorsPerLine": 8,
|
||||||
|
|||||||
@ -267,6 +267,12 @@ authors.
|
|||||||
<td align="center" valign="top" width="12.5%"><a href="https://github.com/shgew"><img src="https://avatars.githubusercontent.com/u/5584672?v=4?s=100" width="100px;" alt="Gleb Shevchenko"/><br /><sub><b>Gleb Shevchenko</b></sub></a><br /><a href="#content-shgew" title="Content">🖋</a></td>
|
<td align="center" valign="top" width="12.5%"><a href="https://github.com/shgew"><img src="https://avatars.githubusercontent.com/u/5584672?v=4?s=100" width="100px;" alt="Gleb Shevchenko"/><br /><sub><b>Gleb Shevchenko</b></sub></a><br /><a href="#content-shgew" title="Content">🖋</a></td>
|
||||||
<td align="center" valign="top" width="12.5%"><a href="https://github.com/mdmundo"><img src="https://avatars.githubusercontent.com/u/60408300?v=4?s=100" width="100px;" alt="Edmundo Paulino"/><br /><sub><b>Edmundo Paulino</b></sub></a><br /><a href="#infra-mdmundo" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
|
<td align="center" valign="top" width="12.5%"><a href="https://github.com/mdmundo"><img src="https://avatars.githubusercontent.com/u/60408300?v=4?s=100" width="100px;" alt="Edmundo Paulino"/><br /><sub><b>Edmundo Paulino</b></sub></a><br /><a href="#infra-mdmundo" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
|
||||||
<td align="center" valign="top" width="12.5%"><a href="https://github.com/eroullit"><img src="https://avatars.githubusercontent.com/u/301795?v=4?s=100" width="100px;" alt="Emmanuel Roullit"/><br /><sub><b>Emmanuel Roullit</b></sub></a><br /><a href="#infra-eroullit" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
|
<td align="center" valign="top" width="12.5%"><a href="https://github.com/eroullit"><img src="https://avatars.githubusercontent.com/u/301795?v=4?s=100" width="100px;" alt="Emmanuel Roullit"/><br /><sub><b>Emmanuel Roullit</b></sub></a><br /><a href="#infra-eroullit" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
|
||||||
|
<td align="center" valign="top" width="12.5%"><a href="https://nidhalmessaoudi.herokuapp.com"><img src="https://avatars.githubusercontent.com/u/63377412?v=4?s=100" width="100px;" alt="Nidhal Messaoudi"/><br /><sub><b>Nidhal Messaoudi</b></sub></a><br /><a href="https://github.com/rust-lang/rustlings/commits?author=nidhalmessaoudi" title="Code">💻</a></td>
|
||||||
|
<td align="center" valign="top" width="12.5%"><a href="https://github.com/MahdiBM"><img src="https://avatars.githubusercontent.com/u/54685446?v=4?s=100" width="100px;" alt="Mahdi Bahrami"/><br /><sub><b>Mahdi Bahrami</b></sub></a><br /><a href="#tool-MahdiBM" title="Tools">🔧</a></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center" valign="top" width="12.5%"><a href="https://github.com/Nagidal"><img src="https://avatars.githubusercontent.com/u/7075397?v=4?s=100" width="100px;" alt="Nagidal"/><br /><sub><b>Nagidal</b></sub></a><br /><a href="#content-Nagidal" title="Content">🖋</a></td>
|
||||||
|
<td align="center" valign="top" width="12.5%"><a href="https://adabrew.com"><img src="https://avatars.githubusercontent.com/u/25161597?v=4?s=100" width="100px;" alt="Adam Brewer"/><br /><sub><b>Adam Brewer</b></sub></a><br /><a href="#content-adamhb123" title="Content">🖋</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
16
CHANGELOG.md
16
CHANGELOG.md
@ -1,3 +1,19 @@
|
|||||||
|
<a name="5.4.1"></a>
|
||||||
|
## 5.4.1 (2023-03-10)
|
||||||
|
|
||||||
|
#### Changed
|
||||||
|
|
||||||
|
- `vecs`: Added links to `iter_mut` and `map` to README.md
|
||||||
|
- `cow1`: Changed main to tests
|
||||||
|
- `iterators1`: Formatted according to rustfmt
|
||||||
|
|
||||||
|
#### Fixed
|
||||||
|
|
||||||
|
- `errors5`: Unified undisclosed type notation
|
||||||
|
- `arc1`: Improved readability by avoiding implicit dereference
|
||||||
|
- `macros4`: Prevented auto-fix by adding `#[rustfmt::skip]`
|
||||||
|
- `cli`: Actually show correct progress percentages
|
||||||
|
|
||||||
<a name="5.4.0"></a>
|
<a name="5.4.0"></a>
|
||||||
|
|
||||||
## 5.4.0 (2023-02-12)
|
## 5.4.0 (2023-02-12)
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "rustlings"
|
name = "rustlings"
|
||||||
version = "5.4.0"
|
version = "5.4.1"
|
||||||
authors = [
|
authors = [
|
||||||
"Liv <mokou@fastmail.com>",
|
"Liv <mokou@fastmail.com>",
|
||||||
"Carol (Nichols || Goulding) <carol.nichols@gmail.com>",
|
"Carol (Nichols || Goulding) <carol.nichols@gmail.com>",
|
||||||
|
|||||||
@ -33,8 +33,8 @@ This will install Rustlings and give you access to the `rustlings` command. Run
|
|||||||
Basically: Clone the repository at the latest tag, finally run `nix develop` or `nix-shell`.
|
Basically: Clone the repository at the latest tag, finally run `nix develop` or `nix-shell`.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# find out the latest version at https://github.com/rust-lang/rustlings/releases/latest (on edit 5.4.0)
|
# find out the latest version at https://github.com/rust-lang/rustlings/releases/latest (on edit 5.4.1)
|
||||||
git clone -b 5.4.0 --depth 1 https://github.com/rust-lang/rustlings
|
git clone -b 5.4.1 --depth 1 https://github.com/rust-lang/rustlings
|
||||||
cd rustlings
|
cd rustlings
|
||||||
# if nix version > 2.3
|
# if nix version > 2.3
|
||||||
nix develop
|
nix develop
|
||||||
@ -71,8 +71,8 @@ If you get a permission denied message, you might have to exclude the directory
|
|||||||
Basically: Clone the repository at the latest tag, run `cargo install --path .`.
|
Basically: Clone the repository at the latest tag, run `cargo install --path .`.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# find out the latest version at https://github.com/rust-lang/rustlings/releases/latest (on edit 5.4.0)
|
# find out the latest version at https://github.com/rust-lang/rustlings/releases/latest (on edit 5.4.1)
|
||||||
git clone -b 5.4.0 --depth 1 https://github.com/rust-lang/rustlings
|
git clone -b 5.4.1 --depth 1 https://github.com/rust-lang/rustlings
|
||||||
cd rustlings
|
cd rustlings
|
||||||
cargo install --force --path .
|
cargo install --force --path .
|
||||||
```
|
```
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
// Execute `rustlings hint vecs2` or use the `hint` watch subcommand for a hint.
|
// Execute `rustlings hint vecs2` or use the `hint` watch subcommand for a hint.
|
||||||
|
|
||||||
fn vec_loop(mut v: Vec<i32>) -> Vec<i32> {
|
fn vec_loop(mut v: Vec<i32>) -> Vec<i32> {
|
||||||
for i in v.iter_mut() {
|
for element in v.iter_mut() {
|
||||||
// TODO: Fill this up so that each element in the Vec `v` is
|
// TODO: Fill this up so that each element in the Vec `v` is
|
||||||
// multiplied by 2.
|
// multiplied by 2.
|
||||||
*i = *i * 2;
|
*i = *i * 2;
|
||||||
@ -19,10 +19,10 @@ fn vec_loop(mut v: Vec<i32>) -> Vec<i32> {
|
|||||||
|
|
||||||
fn vec_map(v: &Vec<i32>) -> Vec<i32> {
|
fn vec_map(v: &Vec<i32>) -> Vec<i32> {
|
||||||
v.iter()
|
v.iter()
|
||||||
.map(|num| {
|
.map(|element| {
|
||||||
// TODO: Do the same thing as above - but instead of mutating the
|
// TODO: Do the same thing as above - but instead of mutating the
|
||||||
// Vec, you can just return the new number!
|
// Vec, you can just return the new number!
|
||||||
num * 2
|
element * 2
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
rustlings =
|
rustlings =
|
||||||
pkgs.rustPlatform.buildRustPackage {
|
pkgs.rustPlatform.buildRustPackage {
|
||||||
name = "rustlings";
|
name = "rustlings";
|
||||||
version = "5.4.0";
|
version = "5.4.1";
|
||||||
|
|
||||||
buildInputs = cargoBuildInputs;
|
buildInputs = cargoBuildInputs;
|
||||||
|
|
||||||
|
|||||||
@ -439,7 +439,9 @@ mode = "compile"
|
|||||||
hint = """
|
hint = """
|
||||||
Yes, it would be really easy to fix this by just changing the value bound to `word` to be a
|
Yes, it would be really easy to fix this by just changing the value bound to `word` to be a
|
||||||
string slice instead of a `String`, wouldn't it?? There is a way to add one character to line
|
string slice instead of a `String`, wouldn't it?? There is a way to add one character to line
|
||||||
9, though, that will coerce the `String` into a string slice."""
|
9, though, that will coerce the `String` into a string slice.
|
||||||
|
|
||||||
|
Side note: If you're interested in learning about how this kind of reference conversion works, you can jump ahead in the book and read this part in the smart pointers chapter: https://doc.rust-lang.org/stable/book/ch15-02-deref.html#implicit-deref-coercions-with-functions-and-methods"""
|
||||||
|
|
||||||
[[exercises]]
|
[[exercises]]
|
||||||
name = "strings3"
|
name = "strings3"
|
||||||
|
|||||||
@ -141,7 +141,7 @@ git clone -q https://github.com/rust-lang/rustlings "$Path"
|
|||||||
|
|
||||||
cd "$Path"
|
cd "$Path"
|
||||||
|
|
||||||
Version=$(curl -s https://api.github.com/repos/rust-lang/rustlings/releases/latest | ${PY} -c "import json,sys;obj=json.load(sys.stdin);print(obj['tag_name']);")
|
Version=$(curl -s https://api.github.com/repos/rust-lang/rustlings/releases/latest | ${PY} -c "import json,sys;obj=json.load(sys.stdin);print(obj['tag_name']) if 'tag_name' in obj else sys.exit(f\"Error: {obj['message']}\");")
|
||||||
CargoBin="${CARGO_HOME:-$HOME/.cargo}/bin"
|
CargoBin="${CARGO_HOME:-$HOME/.cargo}/bin"
|
||||||
|
|
||||||
if [[ -z ${Version} ]]
|
if [[ -z ${Version} ]]
|
||||||
|
|||||||
@ -26,7 +26,7 @@ mod run;
|
|||||||
mod verify;
|
mod verify;
|
||||||
|
|
||||||
// In sync with crate version
|
// In sync with crate version
|
||||||
const VERSION: &str = "5.4.0";
|
const VERSION: &str = "5.4.1";
|
||||||
|
|
||||||
#[derive(FromArgs, PartialEq, Debug)]
|
#[derive(FromArgs, PartialEq, Debug)]
|
||||||
/// Rustlings is a collection of small exercises to get you used to writing and reading Rust code
|
/// Rustlings is a collection of small exercises to get you used to writing and reading Rust code
|
||||||
|
|||||||
@ -13,14 +13,15 @@ pub fn verify<'a>(
|
|||||||
progress: (usize, usize),
|
progress: (usize, usize),
|
||||||
verbose: bool,
|
verbose: bool,
|
||||||
) -> Result<(), &'a Exercise> {
|
) -> Result<(), &'a Exercise> {
|
||||||
let (mut num_done, total) = progress;
|
let (num_done, total) = progress;
|
||||||
let bar = ProgressBar::new(total as u64);
|
let bar = ProgressBar::new(total as u64);
|
||||||
|
let mut percentage = num_done as f32 / total as f32 * 100.0;
|
||||||
bar.set_style(ProgressStyle::default_bar()
|
bar.set_style(ProgressStyle::default_bar()
|
||||||
.template("Progress: [{bar:60.green/red}] {pos}/{len} {msg}")
|
.template("Progress: [{bar:60.green/red}] {pos}/{len} {msg}")
|
||||||
.progress_chars("#>-")
|
.progress_chars("#>-")
|
||||||
);
|
);
|
||||||
bar.set_position(num_done as u64);
|
bar.set_position(num_done as u64);
|
||||||
bar.set_message(format!("({:.1} %)", 0.));
|
bar.set_message(format!("({:.1} %)", percentage));
|
||||||
|
|
||||||
for exercise in exercises {
|
for exercise in exercises {
|
||||||
let compile_result = match exercise.mode {
|
let compile_result = match exercise.mode {
|
||||||
@ -31,8 +32,7 @@ pub fn verify<'a>(
|
|||||||
if !compile_result.unwrap_or(false) {
|
if !compile_result.unwrap_or(false) {
|
||||||
return Err(exercise);
|
return Err(exercise);
|
||||||
}
|
}
|
||||||
num_done += 1;
|
percentage += 100.0 / total as f32;
|
||||||
let percentage = num_done as f32 / total as f32 * 100.0;
|
|
||||||
bar.inc(1);
|
bar.inc(1);
|
||||||
bar.set_message(format!("({:.1} %)", percentage));
|
bar.set_message(format!("({:.1} %)", percentage));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user