@@ -108,15 +108,7 @@ fn main() {
108
108
}
109
109
110
110
if args. nested . is_none ( ) {
111
- println ! ( ) ;
112
- println ! ( r#" welcome to... "# ) ;
113
- println ! ( r#" _ _ _ "# ) ;
114
- println ! ( r#" _ __ _ _ ___| |_| (_)_ __ __ _ ___ "# ) ;
115
- println ! ( r#" | '__| | | / __| __| | | '_ \ / _` / __| "# ) ;
116
- println ! ( r#" | | | |_| \__ \ |_| | | | | | (_| \__ \ "# ) ;
117
- println ! ( r#" |_| \__,_|___/\__|_|_|_| |_|\__, |___/ "# ) ;
118
- println ! ( r#" |___/ "# ) ;
119
- println ! ( ) ;
111
+ println ! ( "\n {}\n " , WELCOME ) ;
120
112
}
121
113
122
114
if !Path :: new ( "info.toml" ) . exists ( ) {
@@ -140,8 +132,7 @@ fn main() {
140
132
let verbose = args. nocapture ;
141
133
142
134
let command = args. nested . unwrap_or_else ( || {
143
- let text = fs:: read_to_string ( "default_out.txt" ) . unwrap ( ) ;
144
- println ! ( "{}" , text) ;
135
+ println ! ( "{}\n " , DEFAULT_OUT ) ;
145
136
std:: process:: exit ( 0 ) ;
146
137
} ) ;
147
138
match command {
@@ -164,9 +155,7 @@ fn main() {
164
155
"Pending"
165
156
} ;
166
157
let solve_cond = {
167
- ( e. looks_done ( ) && subargs. solved )
168
- || ( !e. looks_done ( ) && subargs. unsolved )
169
- || ( !subargs. solved && !subargs. unsolved )
158
+ ( e. looks_done ( ) && subargs. solved ) || ( !e. looks_done ( ) && subargs. unsolved ) || ( !subargs. solved && !subargs. unsolved )
170
159
} ;
171
160
if solve_cond && ( filter_cond || subargs. filter . is_none ( ) ) {
172
161
let line = if subargs. paths {
@@ -219,49 +208,13 @@ fn main() {
219
208
220
209
Subcommands :: Watch ( _subargs) => match watch ( & exercises, verbose) {
221
210
Err ( e) => {
222
- println ! (
223
- "Error: Could not watch your progress. Error message was {:?}." ,
224
- e
225
- ) ;
211
+ println ! ( "Error: Could not watch your progress. Error message was {:?}." , e) ;
226
212
println ! ( "Most likely you've run out of disk space or your 'inotify limit' has been reached." ) ;
227
213
std:: process:: exit ( 1 ) ;
228
214
}
229
215
Ok ( WatchStatus :: Finished ) => {
230
- println ! (
231
- "{emoji} All exercises completed! {emoji}" ,
232
- emoji = Emoji ( "🎉" , "★" )
233
- ) ;
234
- println ! ( ) ;
235
- println ! ( "+----------------------------------------------------+" ) ;
236
- println ! ( "| You made it to the Fe-nish line! |" ) ;
237
- println ! ( "+-------------------------- ------------------------+" ) ;
238
- println ! ( " \\ / " ) ;
239
- println ! ( " ▒▒ ▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒ ▒▒ " ) ;
240
- println ! ( " ▒▒▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒▒▒ " ) ;
241
- println ! ( " ▒▒▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒▒▒ " ) ;
242
- println ! ( " ░░▒▒▒▒░░▒▒ ▒▒ ▒▒ ▒▒ ▒▒░░▒▒▒▒ " ) ;
243
- println ! ( " ▓▓▓▓▓▓▓▓ ▓▓ ▓▓██ ▓▓ ▓▓██ ▓▓ ▓▓▓▓▓▓▓▓ " ) ;
244
- println ! ( " ▒▒▒▒ ▒▒ ████ ▒▒ ████ ▒▒░░ ▒▒▒▒ " ) ;
245
- println ! ( " ▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒ " ) ;
246
- println ! ( " ▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▒▒▒▒▒▒▒▒▓▓▒▒▓▓▒▒▒▒▒▒▒▒ " ) ;
247
- println ! ( " ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ " ) ;
248
- println ! ( " ▒▒▒▒▒▒▒▒▒▒██▒▒▒▒▒▒██▒▒▒▒▒▒▒▒▒▒ " ) ;
249
- println ! ( " ▒▒ ▒▒▒▒▒▒▒▒▒▒██████▒▒▒▒▒▒▒▒▒▒ ▒▒ " ) ;
250
- println ! ( " ▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒ " ) ;
251
- println ! ( " ▒▒ ▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒ ▒▒ " ) ;
252
- println ! ( " ▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒ " ) ;
253
- println ! ( " ▒▒ ▒▒ ▒▒ ▒▒ " ) ;
254
- println ! ( ) ;
255
- println ! ( "We hope you enjoyed learning about the various aspects of Rust!" ) ;
256
- println ! (
257
- "If you noticed any issues, please don't hesitate to report them to our repo."
258
- ) ;
259
- println ! (
260
- "You can also contribute your own exercises to help the greater community!"
261
- ) ;
262
- println ! ( ) ;
263
- println ! ( "Before reporting an issue or contributing, please read our guidelines:" ) ;
264
- println ! ( "https://github.com/rust-lang/rustlings/blob/main/CONTRIBUTING.md" ) ;
216
+ println ! ( "{emoji} All exercises completed! {emoji}" , emoji = Emoji ( "🎉" , "★" ) ) ;
217
+ println ! ( "\n {}\n " , FENISH_LINE ) ;
265
218
}
266
219
Ok ( WatchStatus :: Unfinished ) => {
267
220
println ! ( "We hope you're enjoying learning about Rust!" ) ;
@@ -271,10 +224,7 @@ fn main() {
271
224
}
272
225
}
273
226
274
- fn spawn_watch_shell (
275
- failed_exercise_hint : & Arc < Mutex < Option < String > > > ,
276
- should_quit : Arc < AtomicBool > ,
277
- ) {
227
+ fn spawn_watch_shell ( failed_exercise_hint : & Arc < Mutex < Option < String > > > , should_quit : Arc < AtomicBool > ) {
278
228
let failed_exercise_hint = Arc :: clone ( failed_exercise_hint) ;
279
229
println ! ( "Welcome to watch mode! You can type 'help' to get an overview of the commands you can use here." ) ;
280
230
thread:: spawn ( move || loop {
@@ -311,22 +261,16 @@ fn spawn_watch_shell(
311
261
312
262
fn find_exercise < ' a > ( name : & str , exercises : & ' a [ Exercise ] ) -> & ' a Exercise {
313
263
if name. eq ( "next" ) {
314
- exercises
315
- . iter ( )
316
- . find ( |e| !e. looks_done ( ) )
317
- . unwrap_or_else ( || {
318
- println ! ( "🎉 Congratulations! You have done all the exercises!" ) ;
319
- println ! ( "🔚 There are no more exercises to do next!" ) ;
320
- std:: process:: exit ( 1 )
321
- } )
264
+ exercises. iter ( ) . find ( |e| !e. looks_done ( ) ) . unwrap_or_else ( || {
265
+ println ! ( "🎉 Congratulations! You have done all the exercises!" ) ;
266
+ println ! ( "🔚 There are no more exercises to do next!" ) ;
267
+ std:: process:: exit ( 1 )
268
+ } )
322
269
} else {
323
- exercises
324
- . iter ( )
325
- . find ( |e| e. name == name)
326
- . unwrap_or_else ( || {
327
- println ! ( "No exercise found for '{}'!" , name) ;
328
- std:: process:: exit ( 1 )
329
- } )
270
+ exercises. iter ( ) . find ( |e| e. name == name) . unwrap_or_else ( || {
271
+ println ! ( "No exercise found for '{}'!" , name) ;
272
+ std:: process:: exit ( 1 )
273
+ } )
330
274
}
331
275
}
332
276
@@ -366,11 +310,7 @@ fn watch(exercises: &[Exercise], verbose: bool) -> notify::Result<WatchStatus> {
366
310
. iter ( )
367
311
. skip_while ( |e| !filepath. ends_with ( & e. path ) )
368
312
// .filter(|e| filepath.ends_with(&e.path))
369
- . chain (
370
- exercises
371
- . iter ( )
372
- . filter ( |e| !e. looks_done ( ) && !filepath. ends_with ( & e. path ) ) ,
373
- ) ;
313
+ . chain ( exercises. iter ( ) . filter ( |e| !e. looks_done ( ) && !filepath. ends_with ( & e. path ) ) ) ;
374
314
clear_screen ( ) ;
375
315
match verify ( pending_exercises, verbose) {
376
316
Ok ( _) => return Ok ( WatchStatus :: Finished ) ,
@@ -404,3 +344,64 @@ fn rustc_exists() -> bool {
404
344
. map ( |status| status. success ( ) )
405
345
. unwrap_or ( false )
406
346
}
347
+
348
+ const DEFAULT_OUT : & str = r#"Thanks for installing Rustlings!
349
+
350
+ Is this your first time? Don't worry, Rustlings was made for beginners! We are
351
+ going to teach you a lot of things about Rust, but before we can get
352
+ started, here's a couple of notes about how Rustlings operates:
353
+
354
+ 1. The central concept behind Rustlings is that you solve exercises. These
355
+ exercises usually have some sort of syntax error in them, which will cause
356
+ them to fail compilation or testing. Sometimes there's a logic error instead
357
+ of a syntax error. No matter what error, it's your job to find it and fix it!
358
+ You'll know when you fixed it because then, the exercise will compile and
359
+ Rustlings will be able to move on to the next exercise.
360
+ 2. If you run Rustlings in watch mode (which we recommend), it'll automatically
361
+ start with the first exercise. Don't get confused by an error message popping
362
+ up as soon as you run Rustlings! This is part of the exercise that you're
363
+ supposed to solve, so open the exercise file in an editor and start your
364
+ detective work!
365
+ 3. If you're stuck on an exercise, there is a helpful hint you can view by typing
366
+ 'hint' (in watch mode), or running `rustlings hint exercise_name`.
367
+ 4. If an exercise doesn't make sense to you, feel free to open an issue on GitHub!
368
+ (https://github.com/rust-lang/rustlings/issues/new). We look at every issue,
369
+ and sometimes, other learners do too so you can help each other out!
370
+
371
+ Got all that? Great! To get started, run `rustlings watch` in order to get the first
372
+ exercise. Make sure to have your editor open!"# ;
373
+
374
+ const FENISH_LINE : & str = r#"+----------------------------------------------------+
375
+ | You made it to the Fe-nish line! |
376
+ +-------------------------- ------------------------+
377
+ \\/
378
+ ▒▒ ▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒ ▒▒
379
+ ▒▒▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒▒▒
380
+ ▒▒▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒▒▒
381
+ ░░▒▒▒▒░░▒▒ ▒▒ ▒▒ ▒▒ ▒▒░░▒▒▒▒
382
+ ▓▓▓▓▓▓▓▓ ▓▓ ▓▓██ ▓▓ ▓▓██ ▓▓ ▓▓▓▓▓▓▓▓
383
+ ▒▒▒▒ ▒▒ ████ ▒▒ ████ ▒▒░░ ▒▒▒▒
384
+ ▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒
385
+ ▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▒▒▒▒▒▒▒▒▓▓▒▒▓▓▒▒▒▒▒▒▒▒
386
+ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
387
+ ▒▒▒▒▒▒▒▒▒▒██▒▒▒▒▒▒██▒▒▒▒▒▒▒▒▒▒
388
+ ▒▒ ▒▒▒▒▒▒▒▒▒▒██████▒▒▒▒▒▒▒▒▒▒ ▒▒
389
+ ▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒
390
+ ▒▒ ▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒ ▒▒
391
+ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒
392
+ ▒▒ ▒▒ ▒▒ ▒▒
393
+
394
+ We hope you enjoyed learning about the various aspects of Rust!
395
+ If you noticed any issues, please don't hesitate to report them to our repo.
396
+ You can also contribute your own exercises to help the greater community!
397
+
398
+ Before reporting an issue or contributing, please read our guidelines:
399
+ https://github.com/rust-lang/rustlings/blob/main/CONTRIBUTING.md"# ;
400
+
401
+ const WELCOME : & str = r#" welcome to...
402
+ _ _ _
403
+ _ __ _ _ ___| |_| (_)_ __ __ _ ___
404
+ | '__| | | / __| __| | | '_ \ / _` / __|
405
+ | | | |_| \__ \ |_| | | | | | (_| \__ \
406
+ |_| \__,_|___/\__|_|_|_| |_|\__, |___/
407
+ |___/"# ;
0 commit comments