mirror of
https://github.com/rust-lang/rustlings.git
synced 2024-12-26 00:00:03 +03:00
Merge branch 'main'
This commit is contained in:
commit
92f249a52c
9
.github/workflows/rust.yml
vendored
9
.github/workflows/rust.yml
vendored
|
@ -2,14 +2,19 @@ name: Rustlings Tests
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ main ]
|
branches: [main]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ main ]
|
branches: [main]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
clippy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- run: cargo clippy -- --deny warnings
|
||||||
fmt:
|
fmt:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// A basket of fruits in the form of a hash map needs to be defined. The key
|
// A basket of fruits in the form of a hash map needs to be defined. The key
|
||||||
// represents the name of the fruit and the value represents how many of that
|
// represents the name of the fruit and the value represents how many of that
|
||||||
// particular fruit is in the basket. You have to put at least 3 different
|
// particular fruit is in the basket. You have to put at least 3 different
|
||||||
// types of fruits (e.g apple, banana, mango) in the basket and the total count
|
// types of fruits (e.g. apple, banana, mango) in the basket and the total count
|
||||||
// of all the fruits should be at least 5.
|
// of all the fruits should be at least 5.
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
|
@ -33,7 +33,7 @@ impl Default for Person {
|
||||||
// 5. Extract the other element from the split operation and parse it into a
|
// 5. Extract the other element from the split operation and parse it into a
|
||||||
// `usize` as the age.
|
// `usize` as the age.
|
||||||
// If while parsing the age, something goes wrong, then return the default of
|
// If while parsing the age, something goes wrong, then return the default of
|
||||||
// Person Otherwise, then return an instantiated Person object with the results
|
// Person. Otherwise, then return an instantiated Person object with the results
|
||||||
|
|
||||||
impl From<&str> for Person {
|
impl From<&str> for Person {
|
||||||
fn from(s: &str) -> Person {}
|
fn from(s: &str) -> Person {}
|
||||||
|
|
|
@ -336,7 +336,7 @@ What do you think is the more commonly used pattern under Rust developers?
|
||||||
name = "move_semantics1"
|
name = "move_semantics1"
|
||||||
dir = "06_move_semantics"
|
dir = "06_move_semantics"
|
||||||
hint = """
|
hint = """
|
||||||
So you've got the "cannot borrow immutable local variable `vec` as mutable"
|
So you've got the "cannot borrow `vec` as mutable, as it is not declared as mutable"
|
||||||
error on the line where we push an element to the vector, right?
|
error on the line where we push an element to the vector, right?
|
||||||
|
|
||||||
The fix for this is going to be adding one keyword, and the addition is NOT on
|
The fix for this is going to be adding one keyword, and the addition is NOT on
|
||||||
|
@ -372,7 +372,7 @@ name = "move_semantics4"
|
||||||
dir = "06_move_semantics"
|
dir = "06_move_semantics"
|
||||||
hint = """
|
hint = """
|
||||||
Carefully reason about the range in which each mutable reference is in
|
Carefully reason about the range in which each mutable reference is in
|
||||||
scope. Does it help to update the value of referent (`x`) immediately after
|
scope. Does it help to update the value of `x` immediately after
|
||||||
the mutable reference is taken?
|
the mutable reference is taken?
|
||||||
Read more about 'Mutable References' in the book's section 'References and Borrowing':
|
Read more about 'Mutable References' in the book's section 'References and Borrowing':
|
||||||
https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html#mutable-references.
|
https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html#mutable-references.
|
||||||
|
@ -787,7 +787,7 @@ name = "traits4"
|
||||||
dir = "15_traits"
|
dir = "15_traits"
|
||||||
hint = """
|
hint = """
|
||||||
Instead of using concrete types as parameters you can use traits. Try replacing
|
Instead of using concrete types as parameters you can use traits. Try replacing
|
||||||
the '??' with 'impl <what goes here?>'
|
the '??' with 'impl [what goes here?]'
|
||||||
|
|
||||||
See the documentation at: https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
|
See the documentation at: https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
|
||||||
"""
|
"""
|
||||||
|
@ -798,7 +798,7 @@ dir = "15_traits"
|
||||||
test = false
|
test = false
|
||||||
hint = """
|
hint = """
|
||||||
To ensure a parameter implements multiple traits use the '+ syntax'. Try
|
To ensure a parameter implements multiple traits use the '+ syntax'. Try
|
||||||
replacing the '??' with 'impl <> + <>'.
|
replacing the '??' with 'impl [what goes here?] + [what goes here?]'.
|
||||||
|
|
||||||
See the documentation at: https://doc.rust-lang.org/book/ch10-02-traits.html#specifying-multiple-trait-bounds-with-the--syntax
|
See the documentation at: https://doc.rust-lang.org/book/ch10-02-traits.html#specifying-multiple-trait-bounds-with-the--syntax
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue