mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-09 20:29:18 +00:00
fetch upstream
This commit is contained in:
commit
cd345cd1e4
@ -1074,6 +1074,24 @@
|
||||
"contributions": [
|
||||
"content"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "sundevilyang",
|
||||
"name": "Yang Wen",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/1499214?v=4",
|
||||
"profile": "https://github.com/sundevilyang",
|
||||
"contributions": [
|
||||
"content"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "highb",
|
||||
"name": "Brandon High",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/759848?v=4",
|
||||
"profile": "https://brandon-high.com",
|
||||
"contributions": [
|
||||
"doc"
|
||||
]
|
||||
}
|
||||
],
|
||||
"contributorsPerLine": 8,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
||||
[](#contributors-)
|
||||
[](#contributors-)
|
||||
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
||||
|
||||
# rustlings 🦀❤️
|
||||
@ -16,6 +16,7 @@ Alternatively, for a first-time Rust learner, there are several other resources:
|
||||
## Getting Started
|
||||
|
||||
_Note: If you're on MacOS, make sure you've installed Xcode and its developer tools by typing `xcode-select --install`._
|
||||
_Note: If you're on Linux, make sure you've installed gcc. Deb: `sudo apt install gcc`. Yum: `sudo yum -y install gcc`._
|
||||
|
||||
You will need to have Rust installed. You can get it by visiting https://rustup.rs. This'll also install Cargo, Rust's package/project manager.
|
||||
|
||||
@ -322,6 +323,8 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
||||
<td align="center"><a href="https://github.com/frvannes16"><img src="https://avatars.githubusercontent.com/u/3188475?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Franklin van Nes</b></sub></a><br /><a href="https://github.com/rust-lang/rustlings/commits?author=frvannes16" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://nekonako.github.io"><img src="https://avatars.githubusercontent.com/u/46141275?v=4?s=100" width="100px;" alt=""/><br /><sub><b>nekonako</b></sub></a><br /><a href="https://github.com/rust-lang/rustlings/commits?author=nekonako" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/tan-zx"><img src="https://avatars.githubusercontent.com/u/67887489?v=4?s=100" width="100px;" alt=""/><br /><sub><b>ZX</b></sub></a><br /><a href="#content-tan-zx" title="Content">🖋</a></td>
|
||||
<td align="center"><a href="https://github.com/sundevilyang"><img src="https://avatars.githubusercontent.com/u/1499214?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Yang Wen</b></sub></a><br /><a href="#content-sundevilyang" title="Content">🖋</a></td>
|
||||
<td align="center"><a href="https://brandon-high.com"><img src="https://avatars.githubusercontent.com/u/759848?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Brandon High</b></sub></a><br /><a href="https://github.com/rust-lang/rustlings/commits?author=highb" title="Documentation">📖</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
@ -33,6 +33,7 @@ mod tests {
|
||||
fn explains_why_generating_nametag_text_fails() {
|
||||
assert_eq!(
|
||||
generate_nametag_text("".into()),
|
||||
// Don't change this line
|
||||
Err("`name` was empty; it must be nonempty.".into())
|
||||
);
|
||||
}
|
||||
|
||||
8
exercises/intro/README.md
Normal file
8
exercises/intro/README.md
Normal file
@ -0,0 +1,8 @@
|
||||
# Intro
|
||||
|
||||
Rust uses the `print!` and `println!` macros to print text to the console.
|
||||
|
||||
## Further information
|
||||
|
||||
- [Hello World](https://doc.rust-lang.org/rust-by-example/hello.html)
|
||||
- [Formatted print](https://doc.rust-lang.org/rust-by-example/hello/print.html)
|
||||
23
exercises/intro/intro1.rs
Normal file
23
exercises/intro/intro1.rs
Normal file
@ -0,0 +1,23 @@
|
||||
// intro1.rs
|
||||
// About this `I AM NOT DONE` thing:
|
||||
// We sometimes encourage you to keep trying things on a given exercise, even
|
||||
// after you already figured it out. If you got everything working and feel
|
||||
// ready for the next exercise, remove the `I AM NOT DONE` comment below.
|
||||
// Execute the command `rustlings hint intro1` for a hint.
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
fn main() {
|
||||
println!("Hello and");
|
||||
println!(r#" welcome to... "#);
|
||||
println!(r#" _ _ _ "#);
|
||||
println!(r#" _ __ _ _ ___| |_| (_)_ __ __ _ ___ "#);
|
||||
println!(r#" | '__| | | / __| __| | | '_ \ / _` / __| "#);
|
||||
println!(r#" | | | |_| \__ \ |_| | | | | | (_| \__ \ "#);
|
||||
println!(r#" |_| \__,_|___/\__|_|_|_| |_|\__, |___/ "#);
|
||||
println!(r#" |___/ "#);
|
||||
println!();
|
||||
println!("This exercise compiles successfully. The remaining exercises contain a compiler");
|
||||
println!("or logic error. The central concept behind Rustlings is to fix these errors and");
|
||||
println!("solve the exercises. Good luck!");
|
||||
}
|
||||
9
exercises/intro/intro2.rs
Normal file
9
exercises/intro/intro2.rs
Normal file
@ -0,0 +1,9 @@
|
||||
// intro2.rs
|
||||
// Make the code print a greeting to the world.
|
||||
// Execute `rustlings hint intro2` for a hint.
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
fn main() {
|
||||
println!("Hello {}!");
|
||||
}
|
||||
@ -16,3 +16,5 @@ Option types are very common in Rust code, as they have a number of uses:
|
||||
- [Option Enum Format](https://doc.rust-lang.org/stable/book/ch10-01-syntax.html#in-enum-definitions)
|
||||
- [Option Module Documentation](https://doc.rust-lang.org/std/option/)
|
||||
- [Option Enum Documentation](https://doc.rust-lang.org/std/option/enum.Option.html)
|
||||
- [if let](https://doc.rust-lang.org/rust-by-example/flow_control/if_let.html)
|
||||
- [while let](https://doc.rust-lang.org/rust-by-example/flow_control/while_let.html)
|
||||
|
||||
@ -1,7 +1,13 @@
|
||||
// option1.rs
|
||||
// Make me compile! Execute `rustlings hint option1` for hints
|
||||
|
||||
<<<<<<< HEAD
|
||||
// you can modify anything EXCEPT for this function's sig
|
||||
=======
|
||||
// I AM NOT DONE
|
||||
|
||||
// you can modify anything EXCEPT for this function's signature
|
||||
>>>>>>> upstream/main
|
||||
fn print_number(maybe_number: Option<u16>) {
|
||||
println!("printing: {}", maybe_number.unwrap());
|
||||
}
|
||||
|
||||
@ -14,7 +14,11 @@ struct Package {
|
||||
impl Package {
|
||||
fn new(sender_country: String, recipient_country: String, weight_in_grams: i32) -> Package {
|
||||
if weight_in_grams <= 0 {
|
||||
<<<<<<< HEAD
|
||||
panic!("Attempted to construct a package with negative weight");
|
||||
=======
|
||||
// panic statement goes here...
|
||||
>>>>>>> upstream/main
|
||||
} else {
|
||||
Package {
|
||||
sender_country,
|
||||
|
||||
@ -1,10 +1,6 @@
|
||||
// variables1.rs
|
||||
// Make me compile! Execute the command `rustlings hint variables1` if you want a hint :)
|
||||
|
||||
// About this `I AM NOT DONE` thing:
|
||||
// We sometimes encourage you to keep trying things on a given exercise,
|
||||
// even after you already figured it out. If you got everything working and
|
||||
// feel ready for the next exercise, remove the `I AM NOT DONE` comment below.
|
||||
// Make me compile!
|
||||
// Execute the command `rustlings hint variables1` if you want a hint :)
|
||||
|
||||
fn main() {
|
||||
let x = 5;
|
||||
|
||||
16
info.toml
16
info.toml
@ -1,3 +1,19 @@
|
||||
# INTRO
|
||||
|
||||
[[exercises]]
|
||||
name = "intro1"
|
||||
path = "exercises/intro/intro1.rs"
|
||||
mode = "compile"
|
||||
hint = """
|
||||
Remove the I AM NOT DONE comment to move on to the next exercise."""
|
||||
|
||||
[[exercises]]
|
||||
name = "intro2"
|
||||
path = "exercises/intro/intro2.rs"
|
||||
mode = "compile"
|
||||
hint = """
|
||||
Add an argument after the format string."""
|
||||
|
||||
# VARIABLES
|
||||
|
||||
[[exercises]]
|
||||
|
||||
12
install.sh
12
install.sh
@ -12,6 +12,18 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -x "$(command -v cc)" ]
|
||||
then
|
||||
echo "SUCCESS: cc is installed"
|
||||
else
|
||||
echo "ERROR: cc does not seem to be installed."
|
||||
echo "Please download (g)cc using your package manager."
|
||||
echo "OSX: xcode-select --install"
|
||||
echo "Deb: sudo apt install gcc"
|
||||
echo "Yum: sudo yum -y install gcc"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -x "$(command -v rustc)" ]
|
||||
then
|
||||
echo "SUCCESS: Rust is installed"
|
||||
|
||||
@ -154,7 +154,7 @@ path = "{}.rs""#,
|
||||
Command::new("cargo")
|
||||
.args(&["clippy", "--manifest-path", CLIPPY_CARGO_TOML_PATH])
|
||||
.args(RUSTC_COLOR_ARGS)
|
||||
.args(&["--", "-D", "warnings"])
|
||||
.args(&["--", "-D", "warnings","-D","clippy::float_cmp"])
|
||||
.output()
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user