@@ -14,44 +14,13 @@ pub trait Candidate {
14
14
fn replacement ( & self ) -> & str ;
15
15
}
16
16
17
- impl Candidate for String {
17
+ impl < T : AsRef < str > > Candidate for T {
18
18
fn display ( & self ) -> & str {
19
- self . as_str ( )
19
+ self . as_ref ( )
20
20
}
21
21
22
22
fn replacement ( & self ) -> & str {
23
- self . as_str ( )
24
- }
25
- }
26
-
27
- /// #[deprecated = "Unusable"]
28
- impl Candidate for str {
29
- fn display ( & self ) -> & str {
30
- self
31
- }
32
-
33
- fn replacement ( & self ) -> & str {
34
- self
35
- }
36
- }
37
-
38
- impl Candidate for & ' _ str {
39
- fn display ( & self ) -> & str {
40
- self
41
- }
42
-
43
- fn replacement ( & self ) -> & str {
44
- self
45
- }
46
- }
47
-
48
- impl Candidate for Rc < str > {
49
- fn display ( & self ) -> & str {
50
- self
51
- }
52
-
53
- fn replacement ( & self ) -> & str {
54
- self
23
+ self . as_ref ( )
55
24
}
56
25
}
57
26
@@ -647,4 +616,20 @@ mod tests {
647
616
pub fn normalize ( ) {
648
617
assert_eq ! ( super :: normalize( "Windows" ) , "windows" )
649
618
}
619
+
620
+ #[ test]
621
+ pub fn candidate_impls ( ) {
622
+ struct StrCmp ;
623
+ impl super :: Completer for StrCmp {
624
+ type Candidate = & ' static str ;
625
+ }
626
+ struct RcCmp ;
627
+ impl super :: Completer for RcCmp {
628
+ type Candidate = std:: rc:: Rc < str > ;
629
+ }
630
+ struct ArcCmp ;
631
+ impl super :: Completer for ArcCmp {
632
+ type Candidate = std:: sync:: Arc < str > ;
633
+ }
634
+ }
650
635
}
0 commit comments