diff --git a/rust/series/coverage-annotations.txt b/rust/series/coverage-annotations.txt index 18d42a6c..6a05789f 100644 --- a/rust/series/coverage-annotations.txt +++ b/rust/series/coverage-annotations.txt @@ -27,100 +27,50 @@ 27| 15| match (sequence, span) { 28| 15| (_, span) if span == 0 => { ^3 - 29| | // this corner case, with_zero_length, doesn't make sense + 29| | // this corner case, with_zero_length, doesn't make sense, why isn't the data just an empty vector? 30| 3| vec!["".to_string(); sequence.len() + 1] 31| | } - 32| 12| (sequence, _) if sequence.is_empty() => { - ^0 - 33| | // why are we returning a vector with empty strings? - 34| 0| vec!["".to_string(); sequence.len()] - 35| | } - 36| 12| (sequence, span) if sequence.len() == span => { - ^3 - 37| | // this corner case makes sense - 38| 3| vec![sequence.to_string()] - 39| | } - 40| | // corner case ignored by tests - 41| 9| (sequence, span) if sequence.len() < span => { + 32| 12| (sequence, span) if sequence.len() < span => { ^6 - 42| 6| vec![] - 43| | } - 44| 3| _ => series_main(sequence, span), - 45| | } - 46| 15|} + 33| | // corner case ignored by tests + 34| 6| vec![] + 35| | } + 36| 6| _ => sequence + 37| 6| .chars() + 38| 6| .collect::>() + 39| 6| .windows(span) + 40| 15| .map(|x| x.iter().collect::()) + ------------------ + | series::series::{closure#0}: + | 40| 15| .map(|x| x.iter().collect::()) + ------------------ + | Unexecuted instantiation: series::series::{closure#0} + ------------------ + 41| 6| .collect(), + 42| | } + 43| 15|} ------------------ | series::series: | 26| 15|pub fn series(sequence: &str, span: usize) -> Vec { | 27| 15| match (sequence, span) { | 28| 15| (_, span) if span == 0 => { | ^3 - | 29| | // this corner case, with_zero_length, doesn't make sense + | 29| | // this corner case, with_zero_length, doesn't make sense, why isn't the data just an empty vector? | 30| 3| vec!["".to_string(); sequence.len() + 1] | 31| | } - | 32| 12| (sequence, _) if sequence.is_empty() => { - | ^0 - | 33| | // why are we returning a vector with empty strings? - | 34| 0| vec!["".to_string(); sequence.len()] - | 35| | } - | 36| 12| (sequence, span) if sequence.len() == span => { - | ^3 - | 37| | // this corner case makes sense - | 38| 3| vec![sequence.to_string()] - | 39| | } - | 40| | // corner case ignored by tests - | 41| 9| (sequence, span) if sequence.len() < span => { + | 32| 12| (sequence, span) if sequence.len() < span => { | ^6 - | 42| 6| vec![] - | 43| | } - | 44| 3| _ => series_main(sequence, span), - | 45| | } - | 46| 15|} + | 33| | // corner case ignored by tests + | 34| 6| vec![] + | 35| | } + | 36| 6| _ => sequence + | 37| 6| .chars() + | 38| 6| .collect::>() + | 39| 6| .windows(span) + | 40| 6| .map(|x| x.iter().collect::()) + | 41| 6| .collect(), + | 42| | } + | 43| 15|} ------------------ | Unexecuted instantiation: series::series - ------------------ - 47| | - 48| 3|fn series_main(sequence: &str, span: usize) -> Vec { - 49| 3| // only one test to test the logic of the program? - 50| 3| let mut groups: Vec = vec![]; - 51| 3| let mut remaining: usize = sequence.len(); - 52| | - 53| 15| for (index, _) in sequence.chars().enumerate() { - ^3 - 54| 15| if remaining < span || index + span > sequence.len() { - ^12 - 55| 3| break; - 56| 12| } - 57| 12| remaining -= 1; - 58| 12| - 59| 12| let group: String = sequence[index..span + index].to_string(); - 60| 12| - 61| 12| groups.push(group); - 62| | } - 63| | - 64| 3| groups - 65| 3|} - ------------------ - | series::series_main: - | 48| 3|fn series_main(sequence: &str, span: usize) -> Vec { - | 49| 3| // only one test to test the logic of the program? - | 50| 3| let mut groups: Vec = vec![]; - | 51| 3| let mut remaining: usize = sequence.len(); - | 52| | - | 53| 15| for (index, _) in sequence.chars().enumerate() { - | ^3 - | 54| 15| if remaining < span || index + span > sequence.len() { - | ^12 - | 55| 3| break; - | 56| 12| } - | 57| 12| remaining -= 1; - | 58| 12| - | 59| 12| let group: String = sequence[index..span + index].to_string(); - | 60| 12| - | 61| 12| groups.push(group); - | 62| | } - | 63| | - | 64| 3| groups - | 65| 3|} - ------------------ - | Unexecuted instantiation: series::series_main ------------------ \ No newline at end of file diff --git a/rust/series/coverage-missing-lines.txt b/rust/series/coverage-missing-lines.txt index f1ab21f9..188d921a 100644 --- a/rust/series/coverage-missing-lines.txt +++ b/rust/series/coverage-missing-lines.txt @@ -2,9 +2,7 @@ Running: cargo llvm-cov --no-clean --all-features --workspace --show-missing-lin Filename Regions Missed Regions Cover Functions Missed Functions Executed Lines Missed Lines Cover Branches Missed Branches Cover --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -/home/vpayno/git_vpayno/exercism-workspace/rust/series/src/lib.rs 23 2 91.30% 2 0 100.00% 27 1 96.30% 0 0 - +/home/vpayno/git_vpayno/exercism-workspace/rust/series/src/lib.rs 11 0 100.00% 2 0 100.00% 14 0 100.00% 0 0 - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -TOTAL 23 2 91.30% 2 0 100.00% 27 1 96.30% 0 0 - -Uncovered Lines: -/home/vpayno/git_vpayno/exercism-workspace/rust/series/src/lib.rs: 34 +TOTAL 11 0 100.00% 2 0 100.00% 14 0 100.00% 0 0 - diff --git a/rust/series/report.lcov b/rust/series/report.lcov index 293c7c95..ad45e789 100644 --- a/rust/series/report.lcov +++ b/rust/series/report.lcov @@ -1,11 +1,11 @@ SF:/home/vpayno/git_vpayno/exercism-workspace/rust/series/src/lib.rs -FN:48,_RNvCs3hVIKtMrduI_6series11series_main +FN:40,_RNCNvCs3hVIKtMrduI_6series6series0B3_ FN:26,_RNvCs3hVIKtMrduI_6series6series -FN:48,_RNvCsfpoSPjMhDZV_6series11series_main +FN:40,_RNCNvCsfpoSPjMhDZV_6series6series0B3_ FN:26,_RNvCsfpoSPjMhDZV_6series6series -FNDA:1,_RNvCs3hVIKtMrduI_6series11series_main +FNDA:5,_RNCNvCs3hVIKtMrduI_6series6series0B3_ FNDA:5,_RNvCs3hVIKtMrduI_6series6series -FNDA:0,_RNvCsfpoSPjMhDZV_6series11series_main +FNDA:0,_RNCNvCsfpoSPjMhDZV_6series6series0B3_ FNDA:0,_RNvCsfpoSPjMhDZV_6series6series FNF:2 FNH:2 @@ -14,30 +14,16 @@ DA:27,5 DA:28,5 DA:30,1 DA:32,4 -DA:34,0 -DA:36,4 -DA:38,1 -DA:41,3 -DA:42,2 -DA:44,1 -DA:46,5 -DA:48,1 -DA:49,1 -DA:50,1 -DA:51,1 -DA:53,5 -DA:54,5 -DA:55,1 -DA:56,4 -DA:57,4 -DA:58,4 -DA:59,4 -DA:60,4 -DA:61,4 -DA:64,1 -DA:65,1 +DA:34,2 +DA:36,2 +DA:37,2 +DA:38,2 +DA:39,2 +DA:40,5 +DA:41,2 +DA:43,5 BRF:0 BRH:0 -LF:27 -LH:26 +LF:14 +LH:14 end_of_record \ No newline at end of file diff --git a/rust/series/run-tests-rust.txt b/rust/series/run-tests-rust.txt index ba564ab4..eeacb157 100644 --- a/rust/series/run-tests-rust.txt +++ b/rust/series/run-tests-rust.txt @@ -17,9 +17,9 @@ Rust version: Running: cargo clean -real 0m0.014s -user 0m0.005s -sys 0m0.009s +real 0m0.017s +user 0m0.007s +sys 0m0.010s ============================================================================== @@ -30,22 +30,22 @@ Running: cargo check --future-incompat-report --release Finished release [optimized] target(s) in 0.12s note: 0 dependencies had future-incompatible warnings -real 0m0.130s -user 0m0.033s -sys 0m0.027s +real 0m0.133s +user 0m0.042s +sys 0m0.030s ============================================================================== Exit code: 0 -real 0m0.155s -user 0m0.044s -sys 0m0.042s +real 0m0.171s +user 0m0.061s +sys 0m0.050s -real 0m0.157s -user 0m0.045s -sys 0m0.042s +real 0m0.174s +user 0m0.062s +sys 0m0.052s =============================================================================== @@ -63,9 +63,9 @@ Rust version: Running: cargo clean -real 0m0.008s -user 0m0.003s -sys 0m0.005s +real 0m0.011s +user 0m0.007s +sys 0m0.004s ============================================================================== @@ -75,35 +75,35 @@ Running: cargo clippy --release Checking series v0.1.0 (/home/vpayno/git_vpayno/exercism-workspace/rust/series) Finished release [optimized] target(s) in 0.07s -real 0m0.104s -user 0m0.054s -sys 0m0.049s +real 0m0.101s +user 0m0.047s +sys 0m0.053s ============================================================================== Exit code: 0 -real 0m0.124s -user 0m0.060s -sys 0m0.065s +real 0m0.130s +user 0m0.061s +sys 0m0.070s -real 0m0.126s -user 0m0.060s -sys 0m0.067s +real 0m0.132s +user 0m0.062s +sys 0m0.071s =============================================================================== Running: ../../.github/citools/rust/rust-lint-audit No deps found, skipping cargo audit. -real 0m0.040s -user 0m0.019s -sys 0m0.022s +real 0m0.045s +user 0m0.020s +sys 0m0.026s -real 0m0.041s -user 0m0.019s -sys 0m0.023s +real 0m0.048s +user 0m0.022s +sys 0m0.027s =============================================================================== @@ -126,7 +126,7 @@ Running: cargo clean real 0m0.008s -user 0m0.004s +user 0m0.005s sys 0m0.003s @@ -135,7 +135,7 @@ sys 0m0.003s Running: cargo test --all-features Compiling series v0.1.0 (/home/vpayno/git_vpayno/exercism-workspace/rust/series) - Finished test [unoptimized + debuginfo] target(s) in 0.41s + Finished test [unoptimized + debuginfo] target(s) in 0.35s Running unittests src/lib.rs (target/debug/deps/series-3ab7f72607e10f44) running 0 tests @@ -145,11 +145,11 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; fini Running tests/series.rs (target/debug/deps/series-4fead310f9888830) running 5 tests -test too_long ... ok test way_too_long ... ok test with_length_2 ... ok test with_zero_length ... ok test with_numbers_length ... ok +test too_long ... ok test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s @@ -159,66 +159,66 @@ running 2 tests test src/lib.rs - series (line 17) ... ok test src/lib.rs - series (line 7) ... ok -test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.19s +test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.14s -real 0m0.641s -user 0m0.906s -sys 0m0.380s +real 0m0.518s +user 0m0.694s +sys 0m0.324s ============================================================================== Running: cargo tarpaulin --release --timeout=300 -Sep 19 19:49:23.831  INFO cargo_tarpaulin::config: Creating config -Sep 19 19:49:23.839  INFO cargo_tarpaulin: Running Tarpaulin -Sep 19 19:49:23.840  INFO cargo_tarpaulin: Building project -Sep 19 19:49:23.840  INFO cargo_tarpaulin::cargo: Cleaning project +Sep 19 19:55:30.411  INFO cargo_tarpaulin::config: Creating config +Sep 19 19:55:30.419  INFO cargo_tarpaulin: Running Tarpaulin +Sep 19 19:55:30.420  INFO cargo_tarpaulin: Building project +Sep 19 19:55:30.420  INFO cargo_tarpaulin::cargo: Cleaning project Compiling series v0.1.0 (/home/vpayno/git_vpayno/exercism-workspace/rust/series) - Finished release [optimized] target(s) in 0.63s -Sep 19 19:49:24.516  INFO cargo_tarpaulin::process_handling::linux: Launching test -Sep 19 19:49:24.516  INFO cargo_tarpaulin::process_handling: running /home/vpayno/git_vpayno/exercism-workspace/rust/series/target/release/deps/series-34790761a09df244 + Finished release [optimized] target(s) in 0.55s +Sep 19 19:55:31.020  INFO cargo_tarpaulin::process_handling::linux: Launching test +Sep 19 19:55:31.020  INFO cargo_tarpaulin::process_handling: running /home/vpayno/git_vpayno/exercism-workspace/rust/series/target/release/deps/series-34790761a09df244 running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s -Sep 19 19:49:25.035  INFO cargo_tarpaulin::process_handling::linux: Launching test -Sep 19 19:49:25.035  INFO cargo_tarpaulin::process_handling: running /home/vpayno/git_vpayno/exercism-workspace/rust/series/target/release/deps/series-cf4871a9c0af6f3e +Sep 19 19:55:31.506  INFO cargo_tarpaulin::process_handling::linux: Launching test +Sep 19 19:55:31.506  INFO cargo_tarpaulin::process_handling: running /home/vpayno/git_vpayno/exercism-workspace/rust/series/target/release/deps/series-cf4871a9c0af6f3e running 5 tests test with_zero_length ... ok -test with_numbers_length ... ok +test with_length_2 ... ok test way_too_long ... ok test too_long ... ok -test with_length_2 ... ok +test with_numbers_length ... ok test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s -Sep 19 19:49:25.556  INFO cargo_tarpaulin::report: Coverage Results: +Sep 19 19:55:31.995  INFO cargo_tarpaulin::report: Coverage Results: || Uncovered Lines: || Tested/Total Lines: -|| src/lib.rs: 14/14 +|| src/lib.rs: 4/4 || -100.00% coverage, 14/14 lines covered +100.00% coverage, 4/4 lines covered -real 0m1.741s -user 0m0.752s -sys 0m1.091s +real 0m1.600s +user 0m0.635s +sys 0m1.049s ============================================================================== Exit code: 0 -real 0m2.401s -user 0m1.667s -sys 0m1.482s +real 0m2.140s +user 0m1.340s +sys 0m1.384s -real 0m2.403s -user 0m1.669s -sys 0m1.482s +real 0m2.143s +user 0m1.343s +sys 0m1.384s =============================================================================== @@ -237,7 +237,7 @@ Running: cargo clean real 0m0.014s -user 0m0.006s +user 0m0.005s sys 0m0.008s @@ -247,8 +247,8 @@ Running: cargo llvm-cov clean --workspace real 0m0.188s -user 0m0.104s -sys 0m0.087s +user 0m0.090s +sys 0m0.101s ============================================================================== @@ -263,12 +263,12 @@ running 2 tests test src/lib.rs - series (line 17) ... ok test src/lib.rs - series (line 7) ... ok -test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.16s +test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.14s -real 0m0.321s -user 0m0.349s -sys 0m0.195s +real 0m0.301s +user 0m0.372s +sys 0m0.157s ============================================================================== @@ -276,7 +276,7 @@ sys 0m0.195s Running: cargo llvm-cov --no-clean --all-features --workspace Compiling series v0.1.0 (/home/vpayno/git_vpayno/exercism-workspace/rust/series) - Finished test [unoptimized + debuginfo] target(s) in 0.38s + Finished test [unoptimized + debuginfo] target(s) in 0.34s Running unittests src/lib.rs (target/llvm-cov-target/debug/deps/series-d85f635ebb37f5cc) running 0 tests @@ -296,13 +296,13 @@ test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; fini Filename Regions Missed Regions Cover Functions Missed Functions Executed Lines Missed Lines Cover Branches Missed Branches Cover --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -/home/vpayno/git_vpayno/exercism-workspace/rust/series/src/lib.rs 23 2 91.30% 2 0 100.00% 27 1 96.30% 0 0 - +/home/vpayno/git_vpayno/exercism-workspace/rust/series/src/lib.rs 11 0 100.00% 2 0 100.00% 14 0 100.00% 0 0 - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -TOTAL 23 2 91.30% 2 0 100.00% 27 1 96.30% 0 0 - +TOTAL 11 0 100.00% 2 0 100.00% 14 0 100.00% 0 0 - -real 0m0.511s -user 0m0.370s -sys 0m0.214s +real 0m0.481s +user 0m0.363s +sys 0m0.187s ============================================================================== @@ -312,9 +312,9 @@ Running: cargo llvm-cov report --lcov --output-path report.lcov Finished report saved to report.lcov -real 0m0.123s +real 0m0.146s user 0m0.078s -sys 0m0.048s +sys 0m0.069s Finished test [unoptimized + debuginfo] target(s) in 0.00s Running unittests src/lib.rs (target/llvm-cov-target/debug/deps/series-d85f635ebb37f5cc) @@ -335,9 +335,9 @@ test with_zero_length ... ok test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s -real 0m0.143s -user 0m0.079s -sys 0m0.064s +real 0m0.148s +user 0m0.084s +sys 0m0.063s ============================================================================== @@ -364,9 +364,9 @@ test result: ok. 5 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; fini Finished report saved to coverage-annotations.txt -real 0m0.146s -user 0m0.082s -sys 0m0.067s +real 0m0.142s +user 0m0.073s +sys 0m0.072s ============================================================================== @@ -374,9 +374,9 @@ sys 0m0.067s Running: cargo llvm-cov clean --workspace -real 0m0.133s -user 0m0.068s -sys 0m0.067s +real 0m0.126s +user 0m0.069s +sys 0m0.059s ============================================================================== @@ -388,25 +388,25 @@ Reading tracefile report.lcov Filename |Rate Num|Rate Num|Rate Num ================================================== [/home/vpayno/git_vpayno/exercism-workspace/rust/series/src/] -lib.rs |96.3% 27|50.0% 4| - 0 +lib.rs | 100% 13|50.0% 4| - 0 ================================================== - Total:|96.3% 27|50.0% 4| - 0 + Total:| 100% 13|50.0% 4| - 0 -real 0m0.037s -user 0m0.031s -sys 0m0.006s +real 0m0.043s +user 0m0.035s +sys 0m0.009s Running: lcov --summary report.lcov Reading tracefile report.lcov Summary coverage rate: - lines......: 96.3% (26 of 27 lines) + lines......: 100.0% (13 of 13 lines) functions..: 50.0% (2 of 4 functions) branches...: no data found real 0m0.035s -user 0m0.028s +user 0m0.029s sys 0m0.007s @@ -414,39 +414,39 @@ sys 0m0.007s Exit code: 0 -real 0m1.665s -user 0m1.201s -sys 0m0.771s +real 0m1.637s +user 0m1.205s +sys 0m0.739s -real 0m1.667s -user 0m1.203s -sys 0m0.772s +real 0m1.639s +user 0m1.205s +sys 0m0.740s =============================================================================== Running: misspell . -real 0m0.022s -user 0m0.024s -sys 0m0.014s +real 0m0.023s +user 0m0.019s +sys 0m0.017s =============================================================================== Running: cargo doc Documenting series v0.1.0 (/home/vpayno/git_vpayno/exercism-workspace/rust/series) - Finished dev [unoptimized + debuginfo] target(s) in 0.22s + Finished dev [unoptimized + debuginfo] target(s) in 0.18s -real 0m0.227s -user 0m0.180s -sys 0m0.048s +real 0m0.195s +user 0m0.154s +sys 0m0.042s =============================================================================== Running: cargo clean -real 0m0.012s -user 0m0.005s -sys 0m0.006s +real 0m0.013s +user 0m0.006s +sys 0m0.007s =============================================================================== diff --git a/rust/series/src/lib.rs b/rust/series/src/lib.rs index fe47de24..188f620d 100644 --- a/rust/series/src/lib.rs +++ b/rust/series/src/lib.rs @@ -26,40 +26,18 @@ pub fn series(sequence: &str, span: usize) -> Vec { match (sequence, span) { (_, span) if span == 0 => { - // this corner case, with_zero_length, doesn't make sense + // this corner case, with_zero_length, doesn't make sense, why isn't the data just an empty vector? vec!["".to_string(); sequence.len() + 1] } - (sequence, _) if sequence.is_empty() => { - // why are we returning a vector with empty strings? - vec!["".to_string(); sequence.len()] - } - (sequence, span) if sequence.len() == span => { - // this corner case makes sense - vec![sequence.to_string()] - } - // corner case ignored by tests (sequence, span) if sequence.len() < span => { + // corner case ignored by tests vec![] } - _ => series_main(sequence, span), - } -} - -fn series_main(sequence: &str, span: usize) -> Vec { - // only one test to test the logic of the program? - let mut groups: Vec = vec![]; - let mut remaining: usize = sequence.len(); - - for (index, _) in sequence.chars().enumerate() { - if remaining < span || index + span > sequence.len() { - break; - } - remaining -= 1; - - let group: String = sequence[index..span + index].to_string(); - - groups.push(group); + _ => sequence + .chars() + .collect::>() + .windows(span) + .map(|x| x.iter().collect::()) + .collect(), } - - groups }