From c1de0a0f9ea9863407363ce31bb698e9988215ee Mon Sep 17 00:00:00 2001 From: Marvin Löbel Date: Tue, 17 Feb 2015 22:57:14 +0100 Subject: Added a Pattern impl that delegates to the dereference of a type. This allows to match with a `&String` or `&&str`, for example. --- src/libcoretest/str.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/libcoretest') diff --git a/src/libcoretest/str.rs b/src/libcoretest/str.rs index 9bd7cf9833e..acd8cc42c72 100644 --- a/src/libcoretest/str.rs +++ b/src/libcoretest/str.rs @@ -8,6 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#[test] +fn test_pattern_deref_forward() { + let data = "aabcdaa"; + assert!(data.contains("bcd")); + assert!(data.contains(&"bcd")); + assert!(data.contains(&&"bcd")); + assert!(data.contains(&"bcd".to_string())); + assert!(data.contains(&&"bcd".to_string())); +} + #[test] fn test_empty_match_indices() { let data = "aä中!"; -- cgit 1.4.1-3-g733a5