From 64d95837e9813541cf5b357de13865ce687ae98d Mon Sep 17 00:00:00 2001 From: Adam Brewer Date: Mon, 16 Oct 2023 07:37:12 -0400 Subject: Update Exercises Directory Names to Reflect Order --- exercises/15_traits/traits5.rs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 exercises/15_traits/traits5.rs (limited to 'exercises/15_traits/traits5.rs') diff --git a/exercises/15_traits/traits5.rs b/exercises/15_traits/traits5.rs new file mode 100644 index 0000000..df18380 --- /dev/null +++ b/exercises/15_traits/traits5.rs @@ -0,0 +1,40 @@ +// traits5.rs +// +// Your task is to replace the '??' sections so the code compiles. +// +// Don't change any line other than the marked one. +// +// 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 + } +} + +pub trait OtherTrait { + fn other_function(&self) -> bool { + true + } +} + +struct SomeStruct {} +struct OtherStruct {} + +impl SomeTrait for SomeStruct {} +impl OtherTrait for SomeStruct {} +impl SomeTrait for OtherStruct {} +impl OtherTrait for OtherStruct {} + +// YOU MAY ONLY CHANGE THE NEXT LINE +fn some_func(item: ??) -> bool { + item.some_function() && item.other_function() +} + +fn main() { + some_func(SomeStruct {}); + some_func(OtherStruct {}); +} -- cgit v1.2.3