diff --git a/.all-contributorsrc b/.all-contributorsrc index cc268765..7d26d4cb 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2559,6 +2559,87 @@ "contributions": [ "content" ] + }, + { + "login": "AnonimAnonim2245", + "name": "Luca Plian", + "avatar_url": "https://avatars.githubusercontent.com/u/98339220?v=4", + "profile": "https://github.com/AnonimAnonim2245", + "contributions": [ + "code" + ] + }, + { + "login": "reifenrath-dev", + "name": "RenΓ© Reifenrath", + "avatar_url": "https://avatars.githubusercontent.com/u/18126097?v=4", + "profile": "https://reifenrath.dev/", + "contributions": [ + "content" + ] + }, + { + "login": "peterneave", + "name": "Peter Neave", + "avatar_url": "https://avatars.githubusercontent.com/u/7982708?v=4", + "profile": "https://github.com/peterneave", + "contributions": [ + "infra" + ] + }, + { + "login": "JanB1", + "name": "Jan", + "avatar_url": "https://avatars.githubusercontent.com/u/5552248?v=4", + "profile": "http://www.janb1.com", + "contributions": [ + "content" + ] + }, + { + "login": "kylev", + "name": "Kyle VanderBeek", + "avatar_url": "https://avatars.githubusercontent.com/u/46888?v=4", + "profile": "http://www.kylev.com/", + "contributions": [ + "infra" + ] + }, + { + "login": "pavedroad", + "name": "pavedroad", + "avatar_url": "https://avatars.githubusercontent.com/u/138004431?v=4", + "profile": "https://github.com/pavedroad", + "contributions": [ + "content" + ] + }, + { + "login": "hyphena", + "name": "luna", + "avatar_url": "https://avatars.githubusercontent.com/u/26529488?v=4", + "profile": "https://github.com/hyphena", + "contributions": [ + "content" + ] + }, + { + "login": "evanmiller2112", + "name": "Evan Miller", + "avatar_url": "https://avatars.githubusercontent.com/u/28488957?v=4", + "profile": "https://github.com/evanmiller2112", + "contributions": [ + "content" + ] + }, + { + "login": "luvchurchill", + "name": "luvchurchill", + "avatar_url": "https://avatars.githubusercontent.com/u/46406654?v=4", + "profile": "https://github.com/luvchurchill", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 8, diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index e1b2cec1..f25e8bd8 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,17 +1,8 @@ { - "image": "mcr.microsoft.com/devcontainers/universal:2-linux", - "waitFor": "onCreateCommand", - "onCreateCommand": ".devcontainer/setup.sh", - "updateContentCommand": "cargo build", - "postCreateCommand": "", - "postAttachCommand": { - "server": "rustlings watch" - }, - "customizations": { - "vscode": { - "extensions": [ - "rust-lang.rust-analyzer" - ] - } + "image": "mcr.microsoft.com/devcontainers/rust:1", + "updateContentCommand": ["cargo", "build"], + "postAttachCommand": ["rustlings", "watch"], + "remoteEnv": { + "PATH": "${containerEnv:PATH}:${containerWorkspaceFolder}/target/debug" } } diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh deleted file mode 100755 index 0e090a86..00000000 --- a/.devcontainer/setup.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -curl https://sh.rustup.rs -sSf | sh -s -- -y - -# Update current shell environment variables after install to find rustup -. "$HOME/.cargo/env" -rustup install stable -bash install.sh diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..efdba876 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +* text=auto +*.sh text eol=lf diff --git a/AUTHORS.md b/AUTHORS.md index 5466c9cf..39a3b6bf 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -362,6 +362,17 @@ authors. gerases
gerases

πŸ–‹ + Luca Plian
Luca Plian

πŸ’» + RenΓ© Reifenrath
RenΓ© Reifenrath

πŸ–‹ + Peter Neave
Peter Neave

πŸš‡ + Jan
Jan

πŸ–‹ + Kyle VanderBeek
Kyle VanderBeek

πŸš‡ + pavedroad
pavedroad

πŸ–‹ + luna
luna

πŸ–‹ + + + Evan Miller
Evan Miller

πŸ–‹ + luvchurchill
luvchurchill

πŸ’» diff --git a/CHANGELOG.md b/CHANGELOG.md index a7226a47..a199e4de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -167,7 +167,7 @@ - **structs3**: Clarifed the hint - **quiz2, as_ref_mut, options1, traits1, traits2**: Clarified hints - **traits1, traits2, cli**: Tidied up unmatching backticks -- **enums2**: Removed unneccessary indirection of self +- **enums2**: Removed unnecessary indirection of self - **enums3**: Added an extra tuple comment #### Housekeeping diff --git a/Cargo.lock b/Cargo.lock index 93489eb0..5858d3ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -390,9 +390,9 @@ checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" [[package]] name = "mio" -version = "0.8.9" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "log", diff --git a/exercises/11_hashmaps/hashmaps3.rs b/exercises/11_hashmaps/hashmaps3.rs index 36544ee3..8d9236df 100644 --- a/exercises/11_hashmaps/hashmaps3.rs +++ b/exercises/11_hashmaps/hashmaps3.rs @@ -4,10 +4,11 @@ // the form : ",,," // Example: England,France,4,2 (England scored 4 goals, France 2). // -// You have to build a scores table containing the name of the team, goals the -// team scored, and goals the team conceded. One approach to build the scores -// table is to use a Hashmap. The solution is partially written to use a -// Hashmap, complete it to pass the test. +// You have to build a scores table containing the name of the team, the total +// number of goals the team scored, and the total number of goals the team +// conceded. One approach to build the scores table is to use a Hashmap. +// The solution is partially written to use a Hashmap, +// complete it to pass the test. // // Make me pass the tests! // diff --git a/exercises/23_conversions/from_into.rs b/exercises/23_conversions/from_into.rs index 00f8c2ff..11787c37 100644 --- a/exercises/23_conversions/from_into.rs +++ b/exercises/23_conversions/from_into.rs @@ -24,7 +24,8 @@ impl Default for Person { } } -// Your task is to complete this implementation in order for the line `let p = + +// Your task is to complete this implementation in order for the line `let p1 = // Person::from("Mark,20")` to compile. Please note that you'll need to parse the // age component into a `usize` with something like `"4".parse::()`. The // outcome of this needs to be handled appropriately. @@ -43,8 +44,7 @@ impl Default for Person { // I AM NOT DONE impl From<&str> for Person { - fn from(s: &str) -> Person { - } + fn from(s: &str) -> Person {} } fn main() { @@ -127,14 +127,14 @@ mod tests { #[test] fn test_trailing_comma() { let p: Person = Person::from("Mike,32,"); - assert_eq!(p.name, "Mike"); - assert_eq!(p.age, 32); + assert_eq!(p.name, "John"); + assert_eq!(p.age, 30); } #[test] fn test_trailing_comma_and_some_string() { - let p: Person = Person::from("Mike,32,man"); - assert_eq!(p.name, "Mike"); - assert_eq!(p.age, 32); + let p: Person = Person::from("Mike,32,dog"); + assert_eq!(p.name, "John"); + assert_eq!(p.age, 30); } } diff --git a/info.toml b/info.toml index 887662ab..b1cd64cc 100644 --- a/info.toml +++ b/info.toml @@ -145,7 +145,7 @@ after the `->`. This is where the function's return type should be -- take a look at the `is_even` function for an example! Also: Did you figure out that, technically, `u32` would be the more fitting type -for the prices here, since they can't be negative? If so, kudos!""" +for the inputs of the functions here, since the original prices shouldn't be negative? If so, kudos!""" [[exercises]] name = "functions5" @@ -248,7 +248,7 @@ starting and ending (plus one) indices of the items in the `Array` that you want to end up in the slice. If you're curious why the first argument of `assert_eq!` does not have an -ampersand for a reference since the second argument is areference, take a look +ampersand for a reference since the second argument is a reference, take a look at the coercion chapter of the nomicon: https://doc.rust-lang.org/nomicon/coercions.html""" diff --git a/install.sh b/install.sh index 5915a33d..fdbe8d43 100755 --- a/install.sh +++ b/install.sh @@ -137,7 +137,7 @@ fi Path=${1:-rustlings/} echo "Cloning Rustlings at $Path..." -git clone -q https://github.com/rust-lang/rustlings "$Path" +git clone -q https://github.com/rust-lang/rustlings.git "$Path" cd "$Path" diff --git a/src/ui.rs b/src/ui.rs index 1ee46316..74835e13 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -1,33 +1,28 @@ -macro_rules! warn { - ($fmt:literal, $ex:expr) => {{ +macro_rules! print_emoji { + ($emoji:expr, $sign:expr, $color: ident ,$fmt:literal, $ex:expr) => {{ use console::{style, Emoji}; use std::env; let formatstr = format!($fmt, $ex); if env::var("NO_EMOJI").is_ok() { - println!("{} {}", style("!").red(), style(formatstr).red()); + println!("{} {}", style($sign).$color(), style(formatstr).$color()); } else { println!( "{} {}", - style(Emoji("⚠️ ", "!")).red(), - style(formatstr).red() + style(Emoji($emoji, $sign)).$color(), + style(formatstr).$color() ); } }}; } -macro_rules! success { +macro_rules! warn { ($fmt:literal, $ex:expr) => {{ - use console::{style, Emoji}; - use std::env; - let formatstr = format!($fmt, $ex); - if env::var("NO_EMOJI").is_ok() { - println!("{} {}", style("βœ“").green(), style(formatstr).green()); - } else { - println!( - "{} {}", - style(Emoji("βœ…", "βœ“")).green(), - style(formatstr).green() - ); - } + print_emoji!("⚠️ ", "!", red, $fmt, $ex); + }}; +} + +macro_rules! success { + ($fmt:literal, $ex:expr) => {{ + print_emoji!("βœ… ", "βœ“", green, $fmt, $ex); }}; }