Implement the Contains trait in Rust, which will allow various types to check for the presence of a specific substring or key within them. This trait should be implemented for the following types: String, str, and HashMap<String, V> (where V is any value type).
Requirements:
Trait Definition: Define a trait named Contains with a method has_element(&self, needle: &str) -> bool. This method should check if the needle exists within the type that implements this trait.
Implementations:
String and str: Implement the Contains trait for String and str so that it checks for the presence of the substring within the string.
HashMap<String, V>: Implement the Contains trait for HashMap<String, V> to check if the provided needle exists as a key in the hashmap.
Test Coverage: Ensure that the implementations satisfy the following tests provided in the test code:
For String and str, it should return true if the substring exists and false otherwise.
For HashMap<String, V>, it should return true if the key exists within the hashmap and false if it does not.
Handle both owned strings and borrowed string slices.
File Location: Place the Contains trait and its implementations in the /app/ directory of the project.
By fulfilling these requirements, the existing tests should pass successfully, confirming that the functionality is implemented correctly.