mirror of
https://git.aramjonghu.dev/AramJonghu/rustlings.git
synced 2026-09-04 17:23:36 +02:00
traits2 solution
This commit is contained in:
@@ -755,21 +755,18 @@ https://doc.rust-lang.org/stable/book/ch10-01-syntax.html#in-method-definitions"
|
||||
name = "traits1"
|
||||
dir = "15_traits"
|
||||
hint = """
|
||||
A discussion about Traits in Rust can be found at:
|
||||
https://doc.rust-lang.org/book/ch10-02-traits.html
|
||||
"""
|
||||
More about traits in The Book:
|
||||
https://doc.rust-lang.org/book/ch10-02-traits.html"""
|
||||
|
||||
[[exercises]]
|
||||
name = "traits2"
|
||||
dir = "15_traits"
|
||||
hint = """
|
||||
Notice how the trait takes ownership of `self`, and returns `Self`.
|
||||
Notice how the trait takes ownership of `self` and returns `Self`.
|
||||
|
||||
Try mutating the incoming string vector. Have a look at the tests to see
|
||||
what the result should look like!
|
||||
|
||||
Vectors provide suitable methods for adding an element at the end. See
|
||||
the documentation at: https://doc.rust-lang.org/std/vec/struct.Vec.html"""
|
||||
Although the signature of `append_bar` in the trait takes `self` as argument,
|
||||
the implementation can take `mut self` instead. This is possible because the
|
||||
the value is owned anyway."""
|
||||
|
||||
[[exercises]]
|
||||
name = "traits3"
|
||||
|
||||
Reference in New Issue
Block a user