mirror of
https://github.com/notohh/rustlings.git
synced 2024-12-23 03:38:09 -05:00
46 lines
1 KiB
Rust
46 lines
1 KiB
Rust
// Your task is to replace the '??' sections so the code compiles.
|
|
//
|
|
// Don't change any line other than the marked one.
|
|
|
|
trait Licensed {
|
|
fn licensing_info(&self) -> String {
|
|
"some information".to_string()
|
|
}
|
|
}
|
|
|
|
struct SomeSoftware {}
|
|
|
|
struct OtherSoftware {}
|
|
|
|
impl Licensed for SomeSoftware {}
|
|
impl Licensed for OtherSoftware {}
|
|
|
|
// YOU MAY ONLY CHANGE THE NEXT LINE
|
|
fn compare_license_types(software: ??, software_two: ??) -> bool {
|
|
software.licensing_info() == software_two.licensing_info()
|
|
}
|
|
|
|
fn main() {
|
|
// You can optionally experiment here.
|
|
}
|
|
|
|
#[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));
|
|
}
|
|
}
|