summaryrefslogtreecommitdiff
path: root/exercises
diff options
context:
space:
mode:
authorSam White <theodanwow@gmail.com>2022-02-25 16:41:10 +0000
committermokou <mokou@fastmail.com>2022-07-15 14:13:44 +0200
commit599d634ee2277d1071dd803346993c24ab13462b (patch)
tree9e74e774e6f215ccb14f2fbfb5eeb75b38e2e79f /exercises
parentf43c6d78770ac90725490344dad98b9d3c076484 (diff)
feat: Add traits4.rs exercise
Diffstat (limited to 'exercises')
-rw-r--r--exercises/traits/traits4.rs44
1 files changed, 44 insertions, 0 deletions
diff --git a/exercises/traits/traits4.rs b/exercises/traits/traits4.rs
new file mode 100644
index 0000000..cc5fe16
--- /dev/null
+++ b/exercises/traits/traits4.rs
@@ -0,0 +1,44 @@
+// traits4.rs
+//
+// Your task is to replace the '??' sections so the code compiles.
+// Don't change any line other than 21.
+
+// 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));
+ }
+}