mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-04 01:39:18 +00:00
Refactor some_func to accept a generic type implementing SomeTrait and OtherTrait
This commit is contained in:
parent
1f926b4358
commit
b3fbab1791
@ -7,8 +7,6 @@
|
||||
// Execute `rustlings hint traits5` or use the `hint` watch subcommand for a
|
||||
// hint.
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
pub trait SomeTrait {
|
||||
fn some_function(&self) -> bool {
|
||||
true
|
||||
@ -30,7 +28,7 @@ impl SomeTrait for OtherStruct {}
|
||||
impl OtherTrait for OtherStruct {}
|
||||
|
||||
// YOU MAY ONLY CHANGE THE NEXT LINE
|
||||
fn some_func(item: ??) -> bool {
|
||||
fn some_func<A: SomeTrait + OtherTrait>(item: A) -> bool {
|
||||
item.some_function() && item.other_function()
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user