@@ -74,7 +74,7 @@ pub struct ExpectedMessage {
74
74
impl ExpectedMessage {
75
75
pub fn new ( id : Option < u64 > ) -> ExpectedMessage {
76
76
ExpectedMessage {
77
- id : id ,
77
+ id,
78
78
contains : vec ! [ ] ,
79
79
}
80
80
}
@@ -91,7 +91,7 @@ pub fn read_message<R: Read>(reader: &mut BufReader<R>) -> io::Result<String> {
91
91
loop {
92
92
let mut header = String :: new ( ) ;
93
93
reader. read_line ( & mut header) ?;
94
- if header. len ( ) == 0 {
94
+ if header. is_empty ( ) {
95
95
panic ! ( "eof" )
96
96
}
97
97
if header == "\r \n " {
@@ -146,7 +146,7 @@ pub fn expect_messages<R: Read>(reader: &mut BufReader<R>, expected: &[&Expected
146
146
"Unexpected id"
147
147
) ;
148
148
}
149
- for c in expected. contains . iter ( ) {
149
+ for c in & expected. contains {
150
150
found
151
151
. find ( c)
152
152
. expect ( & format ! ( "Could not find `{}` in `{}`" , c, found) ) ;
@@ -177,7 +177,7 @@ impl RlsHandle {
177
177
let full_msg = format ! ( "Content-Length: {}\r \n \r \n {}" , s. len( ) , s) ;
178
178
self . stdin . write ( full_msg. as_bytes ( ) )
179
179
}
180
- pub fn send ( & mut self , j : serde_json:: Value ) -> io:: Result < usize > {
180
+ pub fn send ( & mut self , j : & serde_json:: Value ) -> io:: Result < usize > {
181
181
self . send_string ( & j. to_string ( ) )
182
182
}
183
183
pub fn notify ( & mut self , method : & str , params : Option < serde_json:: Value > ) -> io:: Result < usize > {
@@ -194,7 +194,7 @@ impl RlsHandle {
194
194
} )
195
195
} ;
196
196
197
- self . send ( message)
197
+ self . send ( & message)
198
198
}
199
199
pub fn request ( & mut self , id : u64 , method : & str , params : Option < serde_json:: Value > ) -> io:: Result < usize > {
200
200
let message = if let Some ( params) = params {
@@ -212,7 +212,7 @@ impl RlsHandle {
212
212
} )
213
213
} ;
214
214
215
- self . send ( message)
215
+ self . send ( & message)
216
216
}
217
217
pub fn shutdown_exit ( & mut self ) {
218
218
self . request ( 99999 , "shutdown" , None ) . unwrap ( ) ;
@@ -242,7 +242,7 @@ struct FileBuilder {
242
242
243
243
impl FileBuilder {
244
244
pub fn new ( path : PathBuf , body : & str ) -> FileBuilder {
245
- FileBuilder { path : path , body : body. to_string ( ) }
245
+ FileBuilder { path, body : body. to_string ( ) }
246
246
}
247
247
248
248
fn mk ( & self ) {
@@ -299,7 +299,7 @@ impl ProjectBuilder {
299
299
// Create the empty directory
300
300
self . root . root . mkdir_p ( ) ;
301
301
302
- for file in self . files . iter ( ) {
302
+ for file in & self . files {
303
303
file. mk ( ) ;
304
304
}
305
305
0 commit comments