mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-07 19:29:18 +00:00
Refactor compare_license_types function
This commit is contained in:
parent
4cf7b33094
commit
1f926b4358
@ -23,7 +23,23 @@ impl Licensed for SomeSoftware {}
|
|||||||
impl Licensed for OtherSoftware {}
|
impl Licensed for OtherSoftware {}
|
||||||
|
|
||||||
// YOU MAY ONLY CHANGE THE NEXT LINE
|
// YOU MAY ONLY CHANGE THE NEXT LINE
|
||||||
fn compare_license_types(software: ??, software_two: ??) -> bool {
|
|
||||||
|
// 1. straight foreword
|
||||||
|
// fn compare_license_types(software: impl Licensed, software_two: impl Licensed) -> bool {
|
||||||
|
// software.licensing_info() == software_two.licensing_info()
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 2. trait bound
|
||||||
|
// fn compare_license_types<T: Licensed, P: Licensed>(software: T, software_two: P) -> bool {
|
||||||
|
// software.licensing_info() == software_two.licensing_info()
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// 3. trait bound + where clause
|
||||||
|
fn compare_license_types<T, P>(software: T, software_two: P) -> bool
|
||||||
|
where T: Licensed,
|
||||||
|
P: Licensed
|
||||||
|
{
|
||||||
software.licensing_info() == software_two.licensing_info()
|
software.licensing_info() == software_two.licensing_info()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user