diff options
| author | Marvin Löbel <loebel.marvin@gmail.com> | 2015-02-17 22:57:14 +0100 |
|---|---|---|
| committer | Marvin Löbel <loebel.marvin@gmail.com> | 2015-02-20 00:58:06 +0100 |
| commit | c1de0a0f9ea9863407363ce31bb698e9988215ee (patch) | |
| tree | ee58e9afdedaddd01673998442a0916d0b801e35 /src/libcoretest | |
| parent | ee930b0262520e25c5b66b037c65dab538ce5e64 (diff) | |
| download | rust-c1de0a0f9ea9863407363ce31bb698e9988215ee.tar.gz rust-c1de0a0f9ea9863407363ce31bb698e9988215ee.zip | |
Added a Pattern impl that delegates to the dereference of a type.
This allows to match with a `&String` or `&&str`, for example.
Diffstat (limited to 'src/libcoretest')
| -rw-r--r-- | src/libcoretest/str.rs | 10 |
1 files changed, 10 insertions, 0 deletions
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 @@ -9,6 +9,16 @@ // 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ä中!"; let vec: Vec<_> = data.match_indices("").collect(); |
