mirror of
https://github.com/notohh/rustlings.git
synced 2024-11-22 14:02:22 -05:00
Merge branch 'main' into main
This commit is contained in:
commit
76acf613c5
12 changed files with 131 additions and 57 deletions
|
@ -2559,6 +2559,87 @@
|
||||||
"contributions": [
|
"contributions": [
|
||||||
"content"
|
"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,
|
"contributorsPerLine": 8,
|
||||||
|
|
|
@ -1,17 +1,8 @@
|
||||||
{
|
{
|
||||||
"image": "mcr.microsoft.com/devcontainers/universal:2-linux",
|
"image": "mcr.microsoft.com/devcontainers/rust:1",
|
||||||
"waitFor": "onCreateCommand",
|
"updateContentCommand": ["cargo", "build"],
|
||||||
"onCreateCommand": ".devcontainer/setup.sh",
|
"postAttachCommand": ["rustlings", "watch"],
|
||||||
"updateContentCommand": "cargo build",
|
"remoteEnv": {
|
||||||
"postCreateCommand": "",
|
"PATH": "${containerEnv:PATH}:${containerWorkspaceFolder}/target/debug"
|
||||||
"postAttachCommand": {
|
|
||||||
"server": "rustlings watch"
|
|
||||||
},
|
|
||||||
"customizations": {
|
|
||||||
"vscode": {
|
|
||||||
"extensions": [
|
|
||||||
"rust-lang.rust-analyzer"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
|
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
* text=auto
|
||||||
|
*.sh text eol=lf
|
11
AUTHORS.md
11
AUTHORS.md
|
@ -362,6 +362,17 @@ authors.
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center" valign="top" width="12.5%"><a href="https://github.com/gerases"><img src="https://avatars.githubusercontent.com/u/8953623?v=4?s=100" width="100px;" alt="gerases"/><br /><sub><b>gerases</b></sub></a><br /><a href="#content-gerases" title="Content">🖋</a></td>
|
<td align="center" valign="top" width="12.5%"><a href="https://github.com/gerases"><img src="https://avatars.githubusercontent.com/u/8953623?v=4?s=100" width="100px;" alt="gerases"/><br /><sub><b>gerases</b></sub></a><br /><a href="#content-gerases" title="Content">🖋</a></td>
|
||||||
|
<td align="center" valign="top" width="12.5%"><a href="https://github.com/AnonimAnonim2245"><img src="https://avatars.githubusercontent.com/u/98339220?v=4?s=100" width="100px;" alt="Luca Plian"/><br /><sub><b>Luca Plian</b></sub></a><br /><a href="https://github.com/rust-lang/rustlings/commits?author=AnonimAnonim2245" title="Code">💻</a></td>
|
||||||
|
<td align="center" valign="top" width="12.5%"><a href="https://reifenrath.dev/"><img src="https://avatars.githubusercontent.com/u/18126097?v=4?s=100" width="100px;" alt="René Reifenrath"/><br /><sub><b>René Reifenrath</b></sub></a><br /><a href="#content-reifenrath-dev" title="Content">🖋</a></td>
|
||||||
|
<td align="center" valign="top" width="12.5%"><a href="https://github.com/peterneave"><img src="https://avatars.githubusercontent.com/u/7982708?v=4?s=100" width="100px;" alt="Peter Neave"/><br /><sub><b>Peter Neave</b></sub></a><br /><a href="#infra-peterneave" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
|
||||||
|
<td align="center" valign="top" width="12.5%"><a href="http://www.janb1.com"><img src="https://avatars.githubusercontent.com/u/5552248?v=4?s=100" width="100px;" alt="Jan"/><br /><sub><b>Jan</b></sub></a><br /><a href="#content-JanB1" title="Content">🖋</a></td>
|
||||||
|
<td align="center" valign="top" width="12.5%"><a href="http://www.kylev.com/"><img src="https://avatars.githubusercontent.com/u/46888?v=4?s=100" width="100px;" alt="Kyle VanderBeek"/><br /><sub><b>Kyle VanderBeek</b></sub></a><br /><a href="#infra-kylev" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
|
||||||
|
<td align="center" valign="top" width="12.5%"><a href="https://github.com/pavedroad"><img src="https://avatars.githubusercontent.com/u/138004431?v=4?s=100" width="100px;" alt="pavedroad"/><br /><sub><b>pavedroad</b></sub></a><br /><a href="#content-pavedroad" title="Content">🖋</a></td>
|
||||||
|
<td align="center" valign="top" width="12.5%"><a href="https://github.com/hyphena"><img src="https://avatars.githubusercontent.com/u/26529488?v=4?s=100" width="100px;" alt="luna"/><br /><sub><b>luna</b></sub></a><br /><a href="#content-hyphena" title="Content">🖋</a></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center" valign="top" width="12.5%"><a href="https://github.com/evanmiller2112"><img src="https://avatars.githubusercontent.com/u/28488957?v=4?s=100" width="100px;" alt="Evan Miller"/><br /><sub><b>Evan Miller</b></sub></a><br /><a href="#content-evanmiller2112" title="Content">🖋</a></td>
|
||||||
|
<td align="center" valign="top" width="12.5%"><a href="https://github.com/luvchurchill"><img src="https://avatars.githubusercontent.com/u/46406654?v=4?s=100" width="100px;" alt="luvchurchill"/><br /><sub><b>luvchurchill</b></sub></a><br /><a href="https://github.com/rust-lang/rustlings/commits?author=luvchurchill" title="Code">💻</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -167,7 +167,7 @@
|
||||||
- **structs3**: Clarifed the hint
|
- **structs3**: Clarifed the hint
|
||||||
- **quiz2, as_ref_mut, options1, traits1, traits2**: Clarified hints
|
- **quiz2, as_ref_mut, options1, traits1, traits2**: Clarified hints
|
||||||
- **traits1, traits2, cli**: Tidied up unmatching backticks
|
- **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
|
- **enums3**: Added an extra tuple comment
|
||||||
|
|
||||||
#### Housekeeping
|
#### Housekeeping
|
||||||
|
|
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -390,9 +390,9 @@ checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mio"
|
name = "mio"
|
||||||
version = "0.8.9"
|
version = "0.8.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0"
|
checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
|
|
|
@ -4,10 +4,11 @@
|
||||||
// the form : "<team_1_name>,<team_2_name>,<team_1_goals>,<team_2_goals>"
|
// the form : "<team_1_name>,<team_2_name>,<team_1_goals>,<team_2_goals>"
|
||||||
// Example: England,France,4,2 (England scored 4 goals, France 2).
|
// 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
|
// You have to build a scores table containing the name of the team, the total
|
||||||
// team scored, and goals the team conceded. One approach to build the scores
|
// number of goals the team scored, and the total number of goals the team
|
||||||
// table is to use a Hashmap. The solution is partially written to use a
|
// conceded. One approach to build the scores table is to use a Hashmap.
|
||||||
// Hashmap, complete it to pass the test.
|
// The solution is partially written to use a Hashmap,
|
||||||
|
// complete it to pass the test.
|
||||||
//
|
//
|
||||||
// Make me pass the tests!
|
// Make me pass the tests!
|
||||||
//
|
//
|
||||||
|
|
|
@ -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
|
// 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::<usize>()`. The
|
// age component into a `usize` with something like `"4".parse::<usize>()`. The
|
||||||
// outcome of this needs to be handled appropriately.
|
// outcome of this needs to be handled appropriately.
|
||||||
|
@ -43,8 +44,7 @@ impl Default for Person {
|
||||||
// I AM NOT DONE
|
// I AM NOT DONE
|
||||||
|
|
||||||
impl From<&str> for Person {
|
impl From<&str> for Person {
|
||||||
fn from(s: &str) -> Person {
|
fn from(s: &str) -> Person {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -127,14 +127,14 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_trailing_comma() {
|
fn test_trailing_comma() {
|
||||||
let p: Person = Person::from("Mike,32,");
|
let p: Person = Person::from("Mike,32,");
|
||||||
assert_eq!(p.name, "Mike");
|
assert_eq!(p.name, "John");
|
||||||
assert_eq!(p.age, 32);
|
assert_eq!(p.age, 30);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_trailing_comma_and_some_string() {
|
fn test_trailing_comma_and_some_string() {
|
||||||
let p: Person = Person::from("Mike,32,man");
|
let p: Person = Person::from("Mike,32,dog");
|
||||||
assert_eq!(p.name, "Mike");
|
assert_eq!(p.name, "John");
|
||||||
assert_eq!(p.age, 32);
|
assert_eq!(p.age, 30);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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!
|
look at the `is_even` function for an example!
|
||||||
|
|
||||||
Also: Did you figure out that, technically, `u32` would be the more fitting type
|
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]]
|
[[exercises]]
|
||||||
name = "functions5"
|
name = "functions5"
|
||||||
|
|
|
@ -137,7 +137,7 @@ fi
|
||||||
|
|
||||||
Path=${1:-rustlings/}
|
Path=${1:-rustlings/}
|
||||||
echo "Cloning Rustlings at $Path..."
|
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"
|
cd "$Path"
|
||||||
|
|
||||||
|
|
31
src/ui.rs
31
src/ui.rs
|
@ -1,33 +1,28 @@
|
||||||
macro_rules! warn {
|
macro_rules! print_emoji {
|
||||||
($fmt:literal, $ex:expr) => {{
|
($emoji:expr, $sign:expr, $color: ident ,$fmt:literal, $ex:expr) => {{
|
||||||
use console::{style, Emoji};
|
use console::{style, Emoji};
|
||||||
use std::env;
|
use std::env;
|
||||||
let formatstr = format!($fmt, $ex);
|
let formatstr = format!($fmt, $ex);
|
||||||
if env::var("NO_EMOJI").is_ok() {
|
if env::var("NO_EMOJI").is_ok() {
|
||||||
println!("{} {}", style("!").red(), style(formatstr).red());
|
println!("{} {}", style($sign).$color(), style(formatstr).$color());
|
||||||
} else {
|
} else {
|
||||||
println!(
|
println!(
|
||||||
"{} {}",
|
"{} {}",
|
||||||
style(Emoji("⚠️ ", "!")).red(),
|
style(Emoji($emoji, $sign)).$color(),
|
||||||
style(formatstr).red()
|
style(formatstr).$color()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! success {
|
macro_rules! warn {
|
||||||
($fmt:literal, $ex:expr) => {{
|
($fmt:literal, $ex:expr) => {{
|
||||||
use console::{style, Emoji};
|
print_emoji!("⚠️ ", "!", red, $fmt, $ex);
|
||||||
use std::env;
|
}};
|
||||||
let formatstr = format!($fmt, $ex);
|
}
|
||||||
if env::var("NO_EMOJI").is_ok() {
|
|
||||||
println!("{} {}", style("✓").green(), style(formatstr).green());
|
macro_rules! success {
|
||||||
} else {
|
($fmt:literal, $ex:expr) => {{
|
||||||
println!(
|
print_emoji!("✅ ", "✓", green, $fmt, $ex);
|
||||||
"{} {}",
|
|
||||||
style(Emoji("✅", "✓")).green(),
|
|
||||||
style(formatstr).green()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue