diff options
| author | Fuwn <[email protected]> | 2021-05-11 14:30:06 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-05-11 14:30:06 +0000 |
| commit | 998d263ea1271eeafca9c90ee1b2cdf3cd157f68 (patch) | |
| tree | e57767fe21c9df140aec6c0e7abcadd2b12bafea | |
| parent | docs: add act documentation, fix up ok docs (diff) | |
| download | whirl-998d263ea1271eeafca9c90ee1b2cdf3cd157f68.tar.xz whirl-998d263ea1271eeafca9c90ee1b2cdf3cd157f68.zip | |
perf(prompt): history builtin use enumerate
Enumerates the vector instead of having a seperate index variable.
| -rw-r--r-- | src/prompt/builtins.rs | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/src/prompt/builtins.rs b/src/prompt/builtins.rs index 6b5da7b..27c0089 100644 --- a/src/prompt/builtins.rs +++ b/src/prompt/builtins.rs @@ -31,10 +31,8 @@ pub fn builtin_echo(args: &[String]) -> i32 { } pub fn builtin_history(history: Vec<String>) -> i32 { - let mut index = 0; - for cmd in &history { + for (index, cmd) in history.iter().enumerate() { println!("{} {}", index, cmd.trim()); - index += 1; } 0 } |