This repository has been archived on 2023-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
rustlings-exercises-completed/exercises/traits/traits4.rs

46 lines
1.1 KiB
Rust
Raw Normal View History

2022-02-25 10:41:10 -06:00
// traits4.rs
//
// Your task is to replace the '??' sections so the code compiles.
// Don't change any line other than 21.
2022-07-15 07:14:48 -05:00
// Execute `rustlings hint traits4` or use the `hint` watch subcommand for a hint.
2022-02-25 10:41:10 -06:00
// I AM NOT DONE
pub trait Licensed {
fn licensing_info(&self) -> String {
"some information".to_string()
}
}
struct SomeSoftware {}
struct OtherSoftware {}
impl Licensed for SomeSoftware {}
impl Licensed for OtherSoftware {}
fn compare_license_types(software: ??, software_two: ??) -> bool {
software.licensing_info() == software_two.licensing_info()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn compare_license_information() {
let some_software = SomeSoftware {};
let other_software = OtherSoftware {};
assert!(compare_license_types(some_software, other_software));
}
#[test]
fn compare_license_information_backwards() {
let some_software = SomeSoftware {};
let other_software = OtherSoftware {};
assert!(compare_license_types(other_software, some_software));
}
}