mirror of
https://github.com/rust-lang/rustlings.git
synced 2025-12-26 00:11:49 +02:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f0c5a8d49 | ||
|
|
3011251da7 | ||
|
|
76b4cb5c00 | ||
|
|
f83af3c25d | ||
|
|
e3931718fb | ||
|
|
4cde86643e | ||
|
|
e696a07190 | ||
|
|
e0db987441 | ||
|
|
1890b0019d | ||
|
|
a750e4a1a3 | ||
|
|
1c789dda08 | ||
|
|
4086d463a9 |
12
CHANGELOG.md
12
CHANGELOG.md
@@ -1,3 +1,15 @@
|
||||
<a name="1.4.1"></a>
|
||||
### 1.4.1 (2019-08-13)
|
||||
|
||||
|
||||
#### Bug Fixes
|
||||
|
||||
* **iterators2:** Remove syntax resulting in misleading error message ([4cde8664](https://github.com/rust-lang/rustlings/commit/4cde86643e12db162a66e62f23b78962986046ac))
|
||||
* **option1:** Add test for prematurely passing exercise ([a750e4a1](https://github.com/rust-lang/rustlings/commit/a750e4a1a3006227292bb17d57d78ce84da6bfc6))
|
||||
* **test1:** Swap assertion parameter order ([4086d463](https://github.com/rust-lang/rustlings/commit/4086d463a981e81d97781851d17db2ced290f446))
|
||||
|
||||
|
||||
|
||||
<a name="1.4.0"></a>
|
||||
## 1.4.0 (2019-07-13)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "rustlings"
|
||||
version = "1.4.0"
|
||||
version = "1.4.1"
|
||||
authors = ["Marisa <marisa@mokou.zone>", "Carol (Nichols || Goulding) <carol.nichols@gmail.com"]
|
||||
edition = "2018"
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// on `None`. Handle this in a more graceful way than calling `unwrap`!
|
||||
// Scroll down for hints :)
|
||||
|
||||
fn main() {
|
||||
pub fn pop_too_much() -> bool {
|
||||
let mut list = vec![3];
|
||||
|
||||
let last = list.pop().unwrap();
|
||||
@@ -15,9 +15,18 @@ fn main() {
|
||||
"The second-to-last item in the list is {:?}",
|
||||
second_to_last
|
||||
);
|
||||
true
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn should_not_panic() {
|
||||
assert!(pop_too_much(), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// iterators2.rs
|
||||
// In this module, you'll learn some of unique advantages that iterators can offer
|
||||
// Step 1. Complete the `capitalize_first` function to pass the first two cases
|
||||
// Step 2. Apply the `capitalize_first` function to a vector of strings, ensuring that it
|
||||
// Step 2. Apply the `capitalize_first` function to a vector of strings, ensuring that it returns a vector of strings as well
|
||||
// Step 3. Apply the `capitalize_first` function again to a list, but try and ensure it returns a single string
|
||||
// As always, there are hints below!
|
||||
|
||||
@@ -9,7 +9,7 @@ pub fn capitalize_first(input: &str) -> String {
|
||||
let mut c = input.chars();
|
||||
match c.next() {
|
||||
None => String::new(),
|
||||
Some(first) => first.collect()::<String>() + c.as_str(),
|
||||
Some(first) => first.collect::<String>() + c.as_str(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ mod tests {
|
||||
|
||||
// Step 1
|
||||
// You need to call something on `first` before it can be collected
|
||||
// Currently it's type is `char`. Have a look at the methods that are available on that type:
|
||||
// Currently its type is `char`. Have a look at the methods that are available on that type:
|
||||
// https://doc.rust-lang.org/std/primitive.char.html
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
### Strings
|
||||
### Structs
|
||||
|
||||
Rust has three struct types: a classic c struct, a tuple struct, and a unit struct.
|
||||
|
||||
|
||||
@@ -16,6 +16,6 @@ fn verify_test() {
|
||||
let price1 = calculate_price(55);
|
||||
let price2 = calculate_price(40);
|
||||
|
||||
assert_eq!(price1, 55);
|
||||
assert_eq!(price2, 80);
|
||||
assert_eq!(55, price1);
|
||||
assert_eq!(80, price2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user