Project: Line Number Filter
Write a program that accepts input from the console or from a re-directed file that prints each line from the input stream. Each line should be prefixed with a line number (padded to 5 spaces, right aligned), followed by a colon, followed by the line from the input stream.
Output
$ rustc LineNumberFilter.rs
error: unknown format trait `d`
--> LineNumberFilter.rs:14:31
|
14 | println!("{}", format!("{0:5d}: {1:s}", lineNumber, line));
| ^
|
= note: the only appropriate formatting traits are:
- ``, which uses the `Display` trait
- `?`, which uses the `Debug` trait
- `e`, which uses the `LowerExp` trait
- `E`, which uses the `UpperExp` trait
- `o`, which uses the `Octal` trait
- `p`, which uses the `Pointer` trait
- `b`, which uses the `Binary` trait
- `x`, which uses the `LowerHex` trait
- `X`, which uses the `UpperHex` trait
error: unknown format trait `s`
--> LineNumberFilter.rs:14:38
|
14 | println!("{}", format!("{0:5d}: {1:s}", lineNumber, line));
| ^
|
= note: the only appropriate formatting traits are:
- ``, which uses the `Display` trait
- `?`, which uses the `Debug` trait
- `e`, which uses the `LowerExp` trait
- `E`, which uses the `UpperExp` trait
- `o`, which uses the `Octal` trait
- `p`, which uses the `Pointer` trait
- `b`, which uses the `Binary` trait
- `x`, which uses the `LowerHex` trait
- `X`, which uses the `UpperHex` trait
error[E0425]: cannot find value `Utils` in this scope
--> LineNumberFilter.rs:13:12
|
13 | line = &(Utils.rtrim(line));
| ^^^^^ not found in this scope
error[E0425]: cannot find function `getline` in this scope
--> LineNumberFilter.rs:12:8
|
12 | while getline(line) {
| ^^^^^^^ not found in this scope
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0425`.