@@ -21,17 +21,13 @@ pub enum ShortcutCommand {
21
21
}
22
22
23
23
#[ derive( PartialEq , Eq , Debug ) ]
24
- pub enum ParseError {
25
- ExpectedEnd ,
26
- }
24
+ pub enum ParseError { }
27
25
28
26
impl std:: error:: Error for ParseError { }
29
27
30
28
impl fmt:: Display for ParseError {
31
- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
32
- match self {
33
- ParseError :: ExpectedEnd => write ! ( f, "expected end of command" ) ,
34
- }
29
+ fn fmt ( & self , _: & mut fmt:: Formatter ) -> fmt:: Result {
30
+ match * self { }
35
31
}
36
32
}
37
33
@@ -49,14 +45,9 @@ impl ShortcutCommand {
49
45
return Ok ( None ) ;
50
46
}
51
47
toks. next_token ( ) ?;
52
- if let Some ( Token :: Dot ) | Some ( Token :: EndOfLine ) = toks. peek_token ( ) ? {
53
- toks. next_token ( ) ?;
54
- * input = toks;
55
- let command = shortcuts. get ( word) . unwrap ( ) ;
56
- return Ok ( Some ( * command) ) ;
57
- } else {
58
- return Err ( toks. error ( ParseError :: ExpectedEnd ) ) ;
59
- }
48
+ * input = toks;
49
+ let command = shortcuts. get ( word) . unwrap ( ) ;
50
+ return Ok ( Some ( * command) ) ;
60
51
}
61
52
Ok ( None )
62
53
}
@@ -70,12 +61,12 @@ fn parse(input: &str) -> Result<Option<ShortcutCommand>, Error<'_>> {
70
61
71
62
#[ test]
72
63
fn test_1 ( ) {
73
- assert_eq ! ( parse( "ready." ) , Ok ( Some ( ShortcutCommand :: Ready ) ) , ) ;
64
+ assert_eq ! ( parse( "ready." ) , Ok ( Some ( ShortcutCommand :: Ready ) ) ) ;
74
65
}
75
66
76
67
#[ test]
77
68
fn test_2 ( ) {
78
- assert_eq ! ( parse( "ready" ) , Ok ( Some ( ShortcutCommand :: Ready ) ) , ) ;
69
+ assert_eq ! ( parse( "ready" ) , Ok ( Some ( ShortcutCommand :: Ready ) ) ) ;
79
70
}
80
71
81
72
#[ test]
@@ -85,15 +76,7 @@ fn test_3() {
85
76
86
77
#[ test]
87
78
fn test_4 ( ) {
88
- use std:: error:: Error ;
89
- assert_eq ! (
90
- parse( "ready word" )
91
- . unwrap_err( )
92
- . source( )
93
- . unwrap( )
94
- . downcast_ref( ) ,
95
- Some ( & ParseError :: ExpectedEnd ) ,
96
- ) ;
79
+ assert_eq ! ( parse( "ready word" ) , Ok ( Some ( ShortcutCommand :: Ready ) ) ) ;
97
80
}
98
81
99
82
#[ test]
0 commit comments