Решение на Форматиране на импорти от Теодор Каракашев
Към профила на Теодор Каракашев
Резултати
- 6 точки от тестове
- 0 бонус точки
- 6 точки общо
- 6 успешни тест(а)
- 14 неуспешни тест(а)
Код
use std::result;
pub struct Import<'a>(pub &'a [&'a str]);
pub enum Order {
Original,
Sorted,
}
pub fn format_nested(imports: &[Import], order: Order) -> Vec<String> {
todo!()
}
pub fn format_flat(imports: &[Import], order: Order) -> Vec<String> {
let mut import_strings: Vec<String> = Vec::new();
for import in imports {
let import_str = import.0.join("::");
if !import_strings.contains(&import_str) {
import_strings.push(import_str);
}
}
if let Order::Sorted = order {
import_strings.sort();
}
import_strings
}
Лог от изпълнението
Compiling solution v0.1.0 (/tmp/d20241203-1739405-x0cb5f/solution) warning: unused import: `std::result` --> src/lib.rs:1:5 | 1 | use std::result; | ^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default warning: unused variable: `imports` --> src/lib.rs:12:22 | 12 | pub fn format_nested(imports: &[Import], order: Order) -> Vec<String> { | ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_imports` | = note: `#[warn(unused_variables)]` on by default warning: unused variable: `order` --> src/lib.rs:12:42 | 12 | pub fn format_nested(imports: &[Import], order: Order) -> Vec<String> { | ^^^^^ help: if this is intentional, prefix it with an underscore: `_order` warning: `solution` (lib) generated 3 warnings Finished test [unoptimized + debuginfo] target(s) in 0.99s Running tests/solution_test.rs (target/debug/deps/solution_test-1428e1090729d165) running 20 tests test solution_test::test_flat_empty ... ok test solution_test::test_flat_multi_crate ... ok test solution_test::test_flat_original ... ok test solution_test::test_flat_sorted ... ok test solution_test::test_flat_original_duplicates ... ok test solution_test::test_flat_sorted_duplicates ... ok test solution_test::test_nested_basic ... FAILED test solution_test::test_nested_deep ... FAILED test solution_test::test_nested_empty ... FAILED test solution_test::test_nested_only_crate ... FAILED test solution_test::test_nested_original ... FAILED test solution_test::test_nested_original_2 ... FAILED test solution_test::test_nested_original_duplicates ... FAILED test solution_test::test_nested_original_multi_crate ... FAILED test solution_test::test_nested_original_self ... FAILED test solution_test::test_nested_sorted ... FAILED test solution_test::test_nested_sorted_2 ... FAILED test solution_test::test_nested_sorted_duplicates ... FAILED test solution_test::test_nested_sorted_multi_crate ... FAILED test solution_test::test_nested_sorted_self ... FAILED failures: ---- solution_test::test_nested_basic stdout ---- thread 'solution_test::test_nested_basic' panicked at 'not yet implemented', src/lib.rs:13:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ---- solution_test::test_nested_deep stdout ---- thread 'solution_test::test_nested_deep' panicked at 'not yet implemented', src/lib.rs:13:5 ---- solution_test::test_nested_empty stdout ---- thread 'solution_test::test_nested_empty' panicked at 'not yet implemented', src/lib.rs:13:5 ---- solution_test::test_nested_only_crate stdout ---- thread 'solution_test::test_nested_only_crate' panicked at 'not yet implemented', src/lib.rs:13:5 ---- solution_test::test_nested_original stdout ---- thread 'solution_test::test_nested_original' panicked at 'not yet implemented', src/lib.rs:13:5 ---- solution_test::test_nested_original_2 stdout ---- thread 'solution_test::test_nested_original_2' panicked at 'not yet implemented', src/lib.rs:13:5 ---- solution_test::test_nested_original_duplicates stdout ---- thread 'solution_test::test_nested_original_duplicates' panicked at 'not yet implemented', src/lib.rs:13:5 ---- solution_test::test_nested_original_multi_crate stdout ---- thread 'solution_test::test_nested_original_multi_crate' panicked at 'not yet implemented', src/lib.rs:13:5 ---- solution_test::test_nested_original_self stdout ---- thread 'solution_test::test_nested_original_self' panicked at 'not yet implemented', src/lib.rs:13:5 ---- solution_test::test_nested_sorted stdout ---- thread 'solution_test::test_nested_sorted' panicked at 'not yet implemented', src/lib.rs:13:5 ---- solution_test::test_nested_sorted_2 stdout ---- thread 'solution_test::test_nested_sorted_2' panicked at 'not yet implemented', src/lib.rs:13:5 ---- solution_test::test_nested_sorted_duplicates stdout ---- thread 'solution_test::test_nested_sorted_duplicates' panicked at 'not yet implemented', src/lib.rs:13:5 ---- solution_test::test_nested_sorted_multi_crate stdout ---- thread 'solution_test::test_nested_sorted_multi_crate' panicked at 'not yet implemented', src/lib.rs:13:5 ---- solution_test::test_nested_sorted_self stdout ---- thread 'solution_test::test_nested_sorted_self' panicked at 'not yet implemented', src/lib.rs:13:5 failures: solution_test::test_nested_basic solution_test::test_nested_deep solution_test::test_nested_empty solution_test::test_nested_only_crate solution_test::test_nested_original solution_test::test_nested_original_2 solution_test::test_nested_original_duplicates solution_test::test_nested_original_multi_crate solution_test::test_nested_original_self solution_test::test_nested_sorted solution_test::test_nested_sorted_2 solution_test::test_nested_sorted_duplicates solution_test::test_nested_sorted_multi_crate solution_test::test_nested_sorted_self test result: FAILED. 6 passed; 14 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s error: test failed, to rerun pass `--test solution_test`